Knowledgize

.shift()

Removes the first element from an array and returns that element.


Examples:

let fruits = ['apple', 'banana', 'orange']; let first = fruits.shift(); console.log(first); // 'apple' console.log(fruits); // ['banana', 'orange']
first = fruits.shift(); console.log(first); // 'banana' console.log(fruits); // ['orange']