Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

JScript Array Object

The Array object provides support for creation of arrays of any data type.

Methods: JScript Array Object

JScript Array Object concat Method

Combines two arrays to make a new array.

JScript Array Object join Method

Converts all elements of an array into a String object and joins them.

JScript Array Object reverse Method

Reverses the elements of an array.

JScript Array Object slice Method

Returns a section of an array.

JScript Array Object sort Method

Sorts the elements of an array.

Properties: JScript Array Object

JScript Array Object length Property

An integer value one higher than the highest element defined in an array.

Syntax: JScript Array Object

new Array()

new Array(size)

new Array(element0, element1, ..., elementn)

Arguments: JScript Array Object

size

The size of the array. As arrays are zero-based, created elements will have indices from zero to size - 1.

element0,...,elementn

The elements to place in the array. This creates an array with n + 1 elements, and a length of n.

Remarks: JScript Array Object

After an array is created, the individual elements of the array can be accessed using [ ] notation, for example:

var my_array = new Array();

for (i = 0; i < 10; i++)

{

my_array[i] = i;

}

x = my_array[4];

Since arrays in Microsoft JScript are zero-based, the last statement in the preceding example accesses the fifth element of the array. That element contains the value 4.

If only one argument is passed to the Array constructor, and it is a number, it is coerced into an unsigned integer and the value is used as the size of the array. Otherwise, the parameter passed in is used as the only element of the array.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.