xxxxxxxxxx
var array = [1, 2, 3, 4, 5];
array.shift(); // Remove first element of the array
console.log(array); // Output: [2, 3, 4, 5]
xxxxxxxxxx
var arr = [1, 2, 3, 4];
var theRemovedElement = arr.shift(); // theRemovedElement == 1
console.log(arr); // [2, 3, 4]
xxxxxxxxxx
// remove the first element with shift
let flowers = ["Rose", "Lily", "Tulip", "Orchid"];
// assigning shift to a variable is not needed if
// you don't need the first element any longer
let removedFlowers = flowers.shift();
console.log(flowers); // ["Lily", "Tulip", "Orchid"]
console.log(removedFlowers); // "Rose"
xxxxxxxxxx
const arr = ['foo', 'bar', 'qux', 'buz'];
arr.shift(); // 'foo'
arr; // ['bar', 'qux', 'buz']
xxxxxxxxxx
var arr = ["f", "o", "o", "b", "a", "r"];
arr.shift();
console.log(arr); // ["o", "o", "b", "a", "r"]
xxxxxxxxxx
const array = [1, 2, 3, 4, 5]; // example array
array.shift(); // removes the first element from the array
console.log(array); // output: [2, 3, 4, 5]