shift() 메서드는 배열에서 첫 번째 요소를 제거하고, 제거된 요소를 반환합니다. 그리고 배열의 길이도 줄어듭니다.
const array1 = [1, 2, 3];
const firstElement = array1.shift();
console.log(array1);
// Expected output: Array [2, 3]
console.log(firstElement);
// Expected output: 1
var myFish = ['angel', 'clown', 'mandarin', 'surgeon'];
console.log('myFish before: ' + myFish);
// "제거전 myFish 배열: angel,clown,mandarin,surgeon"
var shifted = myFish.shift();
console.log('myFish after: ' + myFish);
// "제거후 myFish 배열: clown,mandarin,surgeon"
console.log('Removed this element: ' + shifted);
// "제거된 배열 요소: angel"