Arrays

suggest change

Syntax

Remarks

Arrays are ordered, integer-indexed objects with a special length property and a rich set of iteration and transformation methods. They can hold values of different types, although consistently shaped data is usually easier to work with.

Prefer array literals. A single numeric argument to Array() creates that many empty slots rather than an array containing the number:

console.log(Array(3)); // An array with length 3 and three empty slots.

Use a literal for ordinary values and Array.from() when each generated element needs an initial value:

console.log([3]); // An array containing the number 3.
console.log(Array.from({ length: 3 }, (_, index) => index)); // [0, 1, 2]

Converting Array-like Objects to Arrays

Reducing values

Mapping values

Filtering Object Arrays

Sorting Arrays

Iteration

Removing duplicate elements

Destructuring an array

Array comparison

Reversing arrays

Concatenating Arrays

Shallow cloning an array

Merge two arrays into key-value pairs

Array spread rest

Finding the minimum or maximum element

Removing items from an array

Filtering values

Standard array initialization

Removing all elements

Searching an Array

Convert a String to an Array

Joining array elements in a string

Removing / adding elements using splice

The entries() method

Remove value from array

Logical connective of values

Flattening Arrays

Object keys and values to array

Append / prepend items to array

Checking if an object is an array

Sorting multidimensional array

Insert an item into an array at a specific index

Test all array items for equality

Copy part of an array with slice()

Using map to reformat objects in an array

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents