J

JavaScript Handbook

Clean • Professional

JavaScript Array Reference

3 minute

JavaScript Array Reference

NameDescription
[ ]Creates a new array (array literal syntax).
new Array()Creates a new array (constructor syntax).
at()Returns an indexed element of an array (supports negative indices).
concat()Joins arrays or values and returns a new array.
constructorReturns the function that created the Array prototype.
copyWithin()Copies array elements within the array to specified positions.
entries()Returns an Array Iterator object with key/value pairs.
every()Checks if every element in an array passes a test.
fill()Fills all or part of an array with a static value.
filter()Creates a new array with elements that pass a test.
find()Returns the first element that passes a test.
findIndex()Returns the index of the first element that passes a test.
findLast()Returns the last element that passes a test.
findLastIndex()Returns the index of the last element that passes a test.
flat()Concatenates sub-array elements into a new array (flatten to depth).
flatMap()Maps all array elements and flattens the result by one level.
forEach()Calls a function for each array element.
from()Creates an array from an array-like or iterable object.
includes()Checks if an array contains a specified element.
indexOf()Returns the first index of a specified element, or -1.
isArray()Checks whether an object is an array.
join()Joins all elements into a string with a specified separator.
keys()Returns an Array Iterator object with the keys (indices).
lastIndexOf()Returns the last index of a specified element, or -1.
lengthSets or returns the number of elements in an array.
map()Creates a new array with results of calling a function on each element.
of()Creates an array from a variable number of arguments.
pop()Removes the last element of an array and returns it.
prototypeAllows adding properties and methods to the Array object.
push()Adds new elements to the end of an array and returns the new length.
reduce()Reduces the array to a single value (left-to-right).
reduceRight()Reduces the array to a single value (right-to-left).
reverse()Reverses the order of elements in an array.
shift()Removes the first element of an array and returns it.
slice()Selects a part of an array and returns it as a new array.
some()Checks if any element in an array passes a test.
sort()Sorts the elements of an array in place.
splice()Adds or removes elements from an array.
toReversed()Returns a new array with elements in reversed order (ES2023).
toSorted()Returns a new array with elements sorted (ES2023).
toSpliced()Adds or removes elements at a specified index (ES2023).
toString()Converts an array to a comma-separated string.
unshift()Adds new elements to the beginning of an array and returns new length.
valueOf()Returns the primitive value of an array (same as the array itself).
values()Returns an Array Iterator object with the values of the array.
with()Returns a new array with an element updated at a specified index.
Additional Utilities 
Math.min(...arr)Returns the smallest number from an array (spread required).
Math.max(...arr)Returns the largest number from an array (spread required).
Spread (...)Expands array elements for copying, merging, or passing as arguments.
Rest (...)Collects multiple elements into an array (e.g., function parameters).


Article 0 of 0