JS Array Object

Array object

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

var cars = ["Saab", "Volvo", "BMW"];

The first array element has an index value of 0, the second index value of 1, and so on.

For more information about JavaScript Array, see JavaScript Array Object Manual.

Array properties

constructorReturns the prototype function that creates the array object.
lengthSets or returns the number of array elements.
prototypeAllows you to add properties or methods to array objects.

Array object methods

concat()Concatenate two or more arrays and return the result.
copyWithin()Copies elements from a specified position in the array to another specified location in the array.
entries()Returns an iterable object for an array.
every()Detects whether each element of a numeric element is eligible.
fill()Fill the array with a fixed value.
filter()Detects numeric elements and returns an array of all elements that meet the criteria.
find()Returns an array element that meets the conditions of the incoming test (function).
findIndex()Returns the index of an array element that meets the criteria of the incoming test (function).
forEach()Each element of the array executes a callback function.
from()Creates an array by the given object.
includes()Determines whether an array contains a specified value.
indexOf()Searches for an element in an array and returns its location.
isArray()Determines whether an object is an array.
join()Puts all the elements of the array into a string.
keys()Returns the iterable object of the array, containing the key of the original array.
lastIndexOf()Searches for an element in the array and returns where it last appeared.
map()Processes each element of the array by specifying a function and returns the processed array.
pop()Deletes the last element of the array and returns the deleted element.
push()Adds one or more elements to the end of the array and returns a new length.
reduce()Calculates array elements as a value (left to right).
reduceRight()Calculates the array elements as a value (right to left).
reverse()Reverses the order of the elements of an array.
shift()Deletes and returns the first element of the array.
slice()Picks a part of an array and returns a new array.
some()Detects whether any elements in the array element meet the specified criteria.
sort()Sorts the elements of an array.
splice()Add or remove elements from an array.
toString()Converts an array to a string and returns the result.
unshift()Adds one or more elements to the beginning of the array and returns a new length.
valueOf()Returns the original value of an array object.