push (JavaScript)

Appends elements to an array.

Defined in

Array (Standard - JavaScript)

Syntax

push(object:java.lang.Object, ...) : int
Parameters Description
object The value of a new element. Each parameter represents one new element.
Return value Description
int The new length of the array.

Usage

This method modifies the base array.

Examples

This computed label appends two elements to an array.
var a = new Array("one", "two", "three");
var n = a.push("four", "five");
var display = "";
for(var i=0; i<n; i++) {
	display = display + a[i] + " ";
}
display // one two three four five