/

HTML / CSS / JavaScript Tutorial

JavaScript Array method: unshift()

[this page | pdf | back links]

The unshift() method (when applied to a JavaScript array) adds new elements to the beginning of the array.

 

It has the following syntax with the following parameters. It returns a number, representing the new length of the array.

 

array.unshift(item1, item2, …)

 

Parameter

Required / Optional

Description

item1, item2, …

Required

New item(s) to be added to the array

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Arrays


Desktop view | Switch to Mobile