Array.shift

shift — Removes the first element off an array and returns it.

Description

Array.shift()

Return values

mixed. The value that was removed.

Examples

Example #1 – shift example
var array = [2, 4, 8, 16]; console.log(array); // [2, 4, 8, 16] console.log(array.length); // 4 console.log(array.shift()); // 2 console.log(array); // [4, 8, 16] console.log(array.length); // 3

See also

External references