Array methods
Array.prototype.unshift()
Inserts supplied values at the beginning in argument order, shifts existing positions and returns the new length. Mutates the receiver.
Formal Syntax & Structure
javascript syntaxjavascript
array.unshift(...items)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| items | any | Values to prepend. |
Return Value
Number
New length.
Working Example
Example Snippetjavascript
const a=[4];console.log(a.unshift(1,2),a.join(","));