array
-
[JS]어쩌다 까먹는 자바스크립트 배열 메소드/함수 총정리Algorithm & Data Structure 2022. 3. 13. 01:15
.pop 맨 뒤에 있는 원소를 추출하고 그 원소는 제거된다. const numbers = [10, 20, 30, 40]; const value = numbers.pop(); console.log(value); //40 console.log(numbers); //[10, 20, 30] .push 추가하고 싶은 요소를 맨 뒤에 추가한다. const array = [1, 2, 3, 4, 5]; console.log(array.push(6)) //[1, 2, 3, 4, 5, 6] .unshift 추가하고 싶은 요소를 맨 앞에 추가한다. const numbers = [10, 20, 30, 40]; numbers.unshift(5); console.log(numbers); //[5, 10, 20, 30, 40] ...