[JavaScript] array 배열
배열선언 const array = [273, 'String', true, function () { }, {}, [273, 103]] 이런식으로 [] 안에 선언 push push하면 맨 뒷부분에 추가 된다. 배열.push(요소) 인덱스를 지정해서 삽입하기 비어있는 값은 empty로 출력된다. splice 배열.splice(인덱스, 제거할 요소의 개수) indexOf 요소의 위치값 확인 const itemsB = ['사과', '배', '바나나'] const index = itemsB.indexOf('바나나') index itemsB.splice(index, 1) itemsB itemsB.indexOf('바나나') 바나나는 배열에 없으므로 -1을 출력한다. ◦배열의 특정 위치에 요소 추가 배열.splice(인..
2022. 12. 20.