javascript
This article is a stub. You can help the JavaScript Wiki by expanding it.

Template:Mainonly

An array is a collection of values stored in a list that can be accessed by position. The array literal is a comma-separated list of values enclosed in square brackets.

Visualizing it

The array data-structure is much like a bin of numbered pages. (Whereas the object data-structure is like a file cabinet.)

Members

These properties and methods are available on the global Array constructor.

prototype

Data type object
Standard ECMA-262 §15.4.3.1
Documentation Mozilla, Microsoft

These members are available on each instance of Array. (This includes array literals.)

join

Data type function
Return type string
Parameter list [separator (string)]
Standard ECMA-262 §15.4.4.5
Documentation Mozilla Microsoft

Joins all elements of an array into a string.

separator

Optional. Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma.

splice

Data type function
Return type array
Parameter list index (number), howMany (number), [element1][, ..., elementN] (any type)
Standard ECMA-262 §15.4.4.12
Documentation Mozilla, Microsoft

Changes the content of an array, adding new elements while removing old elements.

index

Index at which to start changing the array. If negative, will begin that many elements from the end.

howMany

An integer indicating the number of old array elements to remove. If howMany is 0, no elements are removed. In this case, you should specify at least one new element.

element1, ..., elementN

Optional. The elements to add to the array. If you don't specify any elements, splice simply removes elements from the array.

forEach

External Links