Arrays
suggest changeSyntax
array = [value,value,…]array = new Array(value,value,…)array = Array.of(value,value,…)array = Array.from(arrayLike)
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
Merge two arrays into key-value pairs
Finding the minimum or maximum element
Joining array elements in a string
Removing / adding elements using splice
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