var myarray = ["item 1", "item 2", "item 3", "item 4"];
//removes the first element of the array, and returns that element.
alert(myarray.shift());
//alerts "item 1"
//removes the last element of the array, and returns that element.
alert(myarray.pop());
//alerts "item 4"
- 첫 번째 배열을 제거하고 첫 번째 요소를 뺀 배열을 반환하는 방법
- 내 예에서는
"item 2", "item 3", "item 4"첫 번째 요소를 제거 해야합니다.
alert(array.slice(1))또는array.shift(); alert(array);