contents   index   previous   next



Array unshift()

syntax:

array.unshift([element1, ...])

where:

elementN - a list of items to insert at the beginning of the array.

 

return:

number - the length of the new array after inserting the items.

 

description:

Any arguments are inserted at the beginning of the array, such that their order within the array is the same as the order in which they appear in the argument list. Note that this method is the opposite of Array push(), which adds the items to the end of the array.

 

see:

Array shift(), Array push()

 

example:

var a = new Array(2,3);

var b = a.unshift(1);