JavaScript

Array객체 메서드indexOf(item, start) item : 찾는 문자start : 시작 index (생략시 0부터)lastIndexOf(item, start)중복된 item index 찾기 (반복문 이용) while(true){    index =  배열.indexOf(fruit, vidx);    if(index== -1){     // index=-1이면 더이상 찾지못함        break;    }    index++;    // 찾은 인덱스부터 검색하면 무한루프가 되어버리기 때문에 꼭 다음 인덱스부터 검색}push(item1, item2, item3 ...) pop()마지막에 저장된 데이터 1개를 꺼냄반환값 : 꺼내진 문자slice(start, end) (기존 배열 유지)start ..
리터럴 객체const 이름 = { key : "value" (변수 추가)메서드 이름: function() { }메서드 이름() { }}메서드 속성 선언 이후 추가시객체이름.변수이름 = 객체이름.메서드 이름 = function(){ } 리터럴 객체 생성 const rect = { key : "value" } 리터럴 객체 생성 const rect = { key : "value" }가로세로를 입력받음 리터럴 객체 생성 const rect = { key : "value" }name과 color를 추가 객체 const 밖에서 속성을 선언하는 것도 가능하다 리터럴 객체 생성 const rect = { key : "value" } ..
배열자바스크립트의 배열 크기는 동적이다 const arr = []const arr = new Array() 배열을 출력하는 법 : 배열(arr)일 경우값을 직접 찍는 방법document.getElementById(res).innerHTML=arr;for문을 활용하여 문자열에 저장for(let i=0; istr+=arr[i]+" "; }forEach(function(문자열, 순서) {} )arr.forEach(function(ar, index){str += ` ${index} 번째 : ${ar} `; })for(x in arr){str += arr[x] + " ";} const arr = [] const arr = new Array() 함수함수 선언식 function 함수이름(매개변수){ ..
모든 document 출력 후 코드 실행하기window.onload=function(){ }수식 (숫자수식 / date수식)변수이름.toLocaleString()함수 선언 방법function aa() { }const aa = function(){ }const aa =() => { } // 화살표 함수스크립트( javascript )에서 html요소로 접근하기document객체 변환 ( String name)값을 가져오기 전에 객체로 먼저 가져와야한다내장 객체 - 문서 - 실행하면 body태그에 코딩된 html요소들이 document객체의 하위 객체로 변환실행된 문서를 document라고 함id 이름을 이용한 접근document.getElementById('id이름');document.querySelect..
아잠만_
'JavaScript' 태그의 글 목록 (2 Page)