new Array(element0, element1, ..., elementN)
An array is an ordered set of values grouped together under a single
variable name created by using an Array object constructor. You
can create an Array literal by specifying the name of the array
and the values of all its elements.
The following example creates an array of three elements:
cars = new Array("Mercedes", "Ford", "Chrysler")
The elements of an array are indexed using their ordinal number, starting
with 0. You could, therefore, refer to the second element in the above
array ("Ford") as 'cars'. You can specify the number of
elements in a new array by using a single numeric parameter with the
For example, the following code creates an array of 7 elements:
fruit = new Array(7)
If you create an array with a single numeric parameter, that number
is stored in the length property, and the array doesn't actually
have any elements until some are specifically assigned to it. If, however,
the parameter is not a number, an array of 1 element is created and
that value assigned to it. You can easily increase the size of an array
by assigning a value to an element higher than its current length.
tag and use a single numeric parameter with the Array constructor,
it will be seen as the value of a single element of the array rather
than the number of elements you want that array to contain.
The constructor property contains the function that created an
The read-only index property for an array created by a regular
expression match and containing the zero-based index of that match.
The read-only input property for an array created by a regular
expression match and containing the original string against which the
match was made.
The length property holds an unsigned 32 bit integer representing
the length of the array. It can be altered independently of the number
of elements in the array.
The prototype property allows the addition of properties to an
The concat method joins two or more Array objects producing
one new one. The original Array objects are unaffected by this
but, if one copy of a string or number is altered, it is not reflected
in the other, whereas a change to an object reference can be seen in
Syntax: Array.concat(arrayName2, arrayName3, ..., arrayNameN)
The join method is used to join all the elements of an array
into a single string separated by a specified string separator (if none
is specified, the default is a comma).
The pop method is used to remove and return the last element
of an array. This affects the length of the array.
The push method is used to add one or more elements to an array,
returning the new length of it. This affects the length of the array.
Syntax: Array.push(element1, ..., elementN)
The reverse method, as the name implies, reverses the order of
the elements in an array making the first last and the last first.
The shift method removes and returns the first element of an
array. This affects the length of the array.
The slice method creates a new array from a selected section
of an array.
The splice method is used to add and/or remove elements of an
Syntax; Array.splice(index, howMany, [element1][, ..., elementN])
The sort method sorts the elements of an array.
The toSource method is inherited from the Object object
and returns the source code of the array. For details see the Object.toSource
The toString method is inherited from the Object object
and returns a string representing the specified array and its elements.
For more details see the Object.toString
The unshift method adds one or more elements to the beginning
of an array and returns the new length.
Syntax: Array.unshift(element1,..., elementN)
The valueOf method is inherited from the Object object
and returns a primitive value for a specified array. For details see
the Object.valueOf method.