Array Object

Top  Previous  Next

An instance of an array.


An array is a sequence of elements that can be referenced by an integer index. If an array has n elements, their indices range from 0 to n-1. You use the member reference operator [] to reference a single element. An array element may be assigned any value or type, including references to other arrays.


When you assign an entire array, you are assigning a reference to the array; the array is not copied.


Creating Arrays

You can create an array with the Array function. You can also create an array with an array literal, which is simply a sequence of values enclosed in brackets (see example below). Some functions and methods also return arrays.

Instance Methods


Converts array elements to strings and concatenates them.

Instance Properties


Gets or sets the number of elements in the array.


var ary1, ary2;

ary1 = Array(10)// 10 uninitialized elements
ary1 = Array(1, true, "test");// 3 initialized elements
ary2 = [10, "literal", ary1];// array literal
ary1 = ary2;// refer to same array

// The original ary1 is still the last element

ary1 = ary1[2];// refers to original array

See Also

Array Function, Member Reference Operators