Array object

The Array objects allow you to perform advanced array manipulations. The Array object can be created using the one of the following syntaxes:

var EmptyArray = new Array();
var TestArray = new Array(10); // create an empty array with 10 items
var DaysArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");


Constructors

Array Creates an empty array object.
Array Creates an array object with the specified number of items.
Array Creates an array object and fills it with the specified items.

Methods

Push Adds one or more items to the end of the array.
Pop Removes a last item from the array and returns it.

Attributes

Type (read only) Returns always "array"
Length Gets or sets the current length of the array, deleting the extra items if necessary.
[index] You can set/get individual items of an array using the usual square bracket notation.

Array()

Creates an empty array object.


Array(NumItems)

Creates an array object with the specified number of items.

Parameters

NumItems
The initial number of items contained in the array

Array(Item1, Item2, Item3, ...)

Creates an array object and fills it with the specified items.

Parameters

ItemX
A value you want to add to the array

Push(Item1, Item2, Items3, ...)

Adds one or more items to the end of the array.

Parameters

ItemX
A value you want to add to the array

Return value

Returns the new length of the array.


Pop()

Removes a last item from the array and returns it.

Return value

Returns the last item of the array.