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"]
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"
1var fruits = ["Banana", "Orange", "Apple", "Mango"];
2fruits.shift();
3// var fruits = ["Orange", "Apple", "Mango"];
1var colors = ["red", "blue", "green"]
2
3var firstColor = colors.shift()
4
5console.log(firstColor) // red
6console.log(colors) // blue green