1var arr = [1, 2, 3, 4];
2var theRemovedElement = arr.shift(); // theRemovedElement == 1
3console.log(arr); // [2, 3, 4]
1pop(): Remove an item from the end of an array.
2push(): Add items to the end of an array.
3shift(): Remove an item from the beginning of an array.
4unshift(): Add items to the beginning of an array.
1
2var list = ["bar", "baz", "foo", "qux"];
3list.shift()//["baz", "foo", "qux"]
1const array1 = [1, 2, 3];
2
3const firstElement = array1.shift();
4
5console.log(array1);
6// expected output: Array [2, 3]
7
8console.log(firstElement);
9// expected output: 1
1var colors = ["red", "green", "blue"];
2var red=colors.shift();
3//colors is now ["green","blue"];