Widely availableSupported across all major browsers. Safe to use in production.

Overview

Arrays are ordered lists of JavaScript values.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
1
18
1

The Array() constructor creates Array objects.

1
12
1
1
18
1

The concat() method of Array instances is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.

1
12
1
1
18
1

The join() method of Array instances creates and returns a new string by concatenating all of the elements in this array, separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.

1
12
1
1
18
1

The length data property of an Array instance represents the number of elements in that array. The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array.

1
12
1
1
18
1

The pop() method of Array instances removes the last element from an array and returns that element. This method changes the length of the array.

1
12
1
1
18
1

The push() method of Array instances adds the specified elements to the end of an array and returns the new length of the array.

1
12
1
1
18
1

The reverse() method of Array instances reverses an array in place and returns the reference to the same array, the first array element now becoming the last, and the last array element becoming the first. In other words, elements order in the array will be turned towards the direction opposite to that previously stated.

1
12
1
1
18
1

The shift() method of Array instances removes the first element from an array and returns that removed element. This method changes the length of the array.

1
12
1
1
18
1

The slice() method of Array instances returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.

1
12
1
1
18
1

The sort() method of Array instances sorts the elements of an array in place and returns the reference to the same array, now sorted. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code unit values.

1
12
1
1
18
1

The toString() method of Array instances returns a string representing the specified array and its elements.

1
12
1
1
18
1

The unshift() method of Array instances adds the specified elements to the beginning of an array and returns the new length of the array.

1
12
1
1
18
1
Other

Arrays can be created using the literal notation:

1
12
1
1
18
1
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
const fruits = ['apple', 'banana', 'cherry'];

// Common methods
fruits.map(f => f.toUpperCase());    // ['APPLE', 'BANANA', 'CHERRY']
fruits.filter(f => f.length > 5);    // ['banana', 'cherry']
fruits.find(f => f.startsWith('b')); // 'banana'
fruits.includes('apple');            // true

// Spread syntax
const more = [...fruits, 'date'];

Live demo

Map — array. Convert

eachelement convertnewarray generate.convertrojk writeTry changing it..

PreviewFullscreen

Filter — condition in clip

filter condition write, color々 clip Try changing it..

PreviewFullscreen

Reduce — reduce

Array 1. Value to and..ka-t. combinegold calculationpracticalexample.

PreviewFullscreen

Use cases

  • Using Array (initial support)

    Arrays are ordered lists of JavaScript values.

Cautions

  • No specific concerns. Stable across all major browsers.

Accessibility

  • When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.

Powered by web-features