xxxxxxxxxx
var arr = ["f", "o", "o", "b", "a", "r"];
arr.shift();
console.log(arr); // ["o", "o", "b", "a", "r"]
xxxxxxxxxx
// example (remove the last element in the array)
let yourArray = ["aaa", "bbb", "ccc", "ddd"];
yourArray.shift(); // yourArray = ["bbb", "ccc", "ddd"]
// syntax:
// <array-name>.shift();
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 array = [1, 2, 3, 4, 5];
array.shift(); // Remove first element of the array
console.log(array); // Output: [2, 3, 4, 5]
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]