Fandom

JavaScript Wiki

Array

87pages on
this wiki
Add New Page
Talk0 Share
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 Edit

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

MembersEdit

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

prototypeEdit

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.)

joinEdit

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.

separatorEdit

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.

spliceEdit

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.

indexEdit

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

howManyEdit

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, ..., elementNEdit

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

forEachEdit

External Links Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.