shift()
noun
say it: “SHIFT” /ʃɪft/
A JavaScript array method that removes the first item from an array, moves everything else up one place, and hands the removed item back.
What does shift() do in JavaScript?
shift() — An Array method that removes and returns the first item.
const line = ["Ada", "Lin"];
const firstGuest = line.shift();
In a sentence
- “Each time a song ends, playlist.shift() takes the next one off the front and plays it.”
Level: Apprentice · More JavaScript terms at this level
Updated