Array.prototype.unshift

Inserts new elements at the start of an array, and returns the new length of the array.

Syntax

unshift(...items)

Parameters

Return value

The new length of the array.

Example

var drinks = ["coffee", "tea"]
drinks.unshift("water")
drinks
["water", "coffee", "tea"]

See also