shift

The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array.1

const names = ['Jack', 'Laura', 'Paul', 'Megan'];
names.shift(); // => 'Jack'
names;
// => ['Laura', 'Paul', 'Megan']

Footnotes

  1. shift, MDN. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift˄


Backlinks