1
2var list = ["bar", "baz", "foo", "qux"];
3list.shift()//["baz", "foo", "qux"]
1//Add element to front of array
2var numbers = ["2", "3", "4", "5"];
3numbers.unshift("1");
4//Result - numbers: ["1", "2", "3", "4", "5"]
1//The shift() method removes the first element from an array
2//and returns that removed element.
3//This method changes the length of the array.
4
5const array1 = [1, 2, 3];
6const firstElement = array1.shift();
7console.log(array1);
8// expected output: Array [2, 3]
9console.log(firstElement);
10// expected output: 1
11
1
2const fruits = ["Banana", "Orange", "Apple", "Mango"];
3
4fruits.shift(); // Removes "Banana" from fruits
5