unshift()

noun

say it: “un-SHIFT” /ʌnˈʃɪft/

A JavaScript array method that adds one or more items to the start of an array, moves everything else back one place, and returns the new length.

What does unshift() do in JavaScript?

unshift() — An Array method that adds values to the beginning and returns the new length.

const line = ["Ada", "Lin"];
const firstGuest = line.shift();

In a sentence

  • “I used unshift() to put the new song at the top of the playlist instead of the bottom.”

Level: Apprentice · More JavaScript terms at this level

Updated