1var arr = [1, 2, 3, 4];
2var theRemovedElement = arr.shift(); // theRemovedElement == 1
3console.log(arr); // [2, 3, 4]
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 arr = ["f", "o", "o", "b", "a", "r"];
2arr.shift();
3console.log(arr); // ["o", "o", "b", "a", "r"]
1// remove the first element with shift
2let flowers = ["Rose", "Lily", "Tulip", "Orchid"];
3
4// assigning shift to a variable is not needed if
5// you don't need the first element any longer
6let removedFlowers = flowers.shift();
7
8console.log(flowers); // ["Lily", "Tulip", "Orchid"]
9console.log(removedFlowers); // "Rose"