JavaScript Array Reference Manual

Array object

The Array object is used to store multiple values in a single variable:

const cars = ["Tesla", "Volvo", "BMW"];

Try it yourself

Array indices start from zero: the first element in the array is 0, the second element is 1, and so on.

For tutorials on arrays, please read our JavaScript Array Tutorial.

Array methods and properties

Method Description
[] Create a new array.
new Array() Create a new array.
at() Return the index element of the array.
concat() Concatenate arrays and return the concatenated array.
constructor Return the function that creates the prototype of the Array object.
copyWithin() Copy array elements to a specified position or from a specified position.
entries() Return an array of key/value pairs from the iterable object.
every() Check if each element in the array passes the test.
fill() Fill the elements in the array with static values.
filter() Create a new array using each element that passes the test in the array.
find() Return the value of the first element in the array that passes the test.
findIndex() Return the index of the first element in the array that passes the test.
findLast() Return the value of the last element in the array that passes the test.
findLastIndex() Return the index of the last element in the array that passes the test.
flat() Concatenate subarray elements.
flatMap() Map all array elements and create a new flat array.
forEach() Call a function for each array element.
from() Create an array from an object.
includes() Check if an array contains a specified element.
indexOf() Search for an element in the array and return its position.
isArray() Check if an object is an array.
join() Join all elements of the array into a single string.
keys() Return an Array Iteration object containing the keys of the original array.
lastIndexOf() Start searching for elements from the end of the array and return their position.
length Set or return the number of elements in the array.
map() Create a new array using the results of calling a function for each array element.
of() Create an array from multiple parameters.
pop() Remove the last element of the array and return the element.
prototype Allows you to add properties and methods to the array.
push() Add a new element to the end of the array and return the new length.
reduce() Reduce the value of the array to a single value (left to right).
reduceRight() Reduce the value of the array to a single value (right to left).
reverse() Reverse the order of elements in the array.
shift() Remove the first element of the array and return the element.
slice() Select a part of the array and return a new array.
some() Check if any element in the array passes the test.
sort() Sort the elements of the array.
splice() Add/remove elements from the array.
toReversed() Reverse the order of array elements (to a new array).
toSorted() Sort the elements of the array (to a new array).
toSpliced() Add or remove array elements (to a new array).
toString() Convert the array to a string and return the result.
unshift() Add a new element to the beginning of the array and return the new length.
values() Return an iterator object containing the array values.
valueOf() Return the original value of the array.
with() Return a new array with the updated elements.