shift()
ES3+Removes the first element from an array and returns that element.
Syntax
array.shift()Return Value
any
The removed element
Examples
JavaScript
const fruits = ['apple', 'banana', 'cherry'];
const first = fruits.shift();
console.log(first);
console.log(fruits); Output:
// 'apple'
['banana', 'cherry']