← Reference

Array Methods

Methods available on every JavaScript Array instance.

Array.prototype..from()

Create a shallow-copied array from an array-like or iterable object.

Array.from(arrayLike, mapFn?, thisArg?)

Array.prototype..isArray()

Check if a value is an array using the reliable Array.isArray() method.

Array.isArray(value)

Array.prototype..of()

Create an array from variadic arguments, ensuring each element is preserved without the array-like argument gotchas that affect Array constructor calls.

Array.of(...elements)

Array.prototype.at()

Access array elements by negative or positive index. The at() method accepts negative indices to count from the end.

at(index)

Array.prototype.concat()

Merge two or more arrays together. The concat() method returns a new array containing all the elements from the original array(s) without modifying them.

concat(...items)

Array.prototype.copyWithin()

Shallow copies elements within an array to another position in the same array, mutating the array in place.

copyWithin(target, start, end)

Array.prototype.entries()

Returns a new array iterator object that contains the key-value pairs for each index in the array.

entries()

Array.prototype.every()

Test if all array elements pass a condition. Returns true if callback returns truthy for every element.

every(callbackFn)

Array.prototype.fill()

Fill an array with a static value from a start index to an end index, modifying it in place.

fill(value[, start[, end]])

Array.prototype.filter()

Creates a new array with all elements that pass the test implemented by the provided callback function.

filter(callbackFn, thisArg)

Array.prototype.find()

Find the first element in an array that satisfies a test function. Returns undefined if no element matches.

find(callbackFn, thisArg)

Array.prototype.findIndex()

Find the index of the first element that satisfies a test function, or -1 if none match.

findIndex(callbackFn, thisArg)

Array.prototype.findLast()

Find the last element in an array that matches a condition by iterating backwards.

findLast(callbackFn, thisArg)

Array.prototype.findLastIndex()

Find the index of the last element in an array that matches a condition by iterating backwards.

findLastIndex(callbackFn, thisArg)

Array.prototype.flat()

Flatten nested arrays to a specified depth, creating a new array with all sub-array elements concatenated.

flat(depth)

Array.prototype.flatMap()

Map each element and flatten the result into a new array in a single pass.

flatMap(callbackFn, thisArg)

Array.prototype.includes()

Check if an array contains a specific element. Returns true if found, false otherwise.

includes(searchElement, fromIndex?)

Array.prototype.indexOf()

Find the first position of an element in an array. Returns the index or -1 if not found.

indexOf(searchElement, fromIndex)

Array.prototype.join()

Joins all array elements into a string, optionally separated by a custom delimiter.

join(separator)

Array.prototype.keys()

Get an iterator containing the keys (indices) of an array for use in for...of loops.

keys()

Array.prototype.lastIndexOf()

Return the last index at which a given element can be found in the array, or -1 if not found.

lastIndexOf(searchElement, fromIndex)

Array.prototype.map()

Creates a new array with the results of calling a provided function on every element in the calling array.

map(callbackFn, thisArg?)

Array.prototype.pop()

Remove the last element from an array. Returns the removed element.

pop()

Array.prototype.push()

Add one or more elements to the end of an array. Returns the new length.

push(...items)

Array.prototype.reduce()

Reduce an array to a single value by executing a callback function for each element. Use for summing, filtering, or transforming arrays.

reduce(callbackFn, initialValue)

Array.prototype.reduceRight()

Reduce an array from right to left, accumulating values into a single result. Useful for right-associative operations.

reduceRight(callbackFn, initialValue)

Array.prototype.shift()

Remove the first element from an array. Returns the removed element.

shift()

Array.prototype.some()

Test if at least one array element passes a given function.

some(callbackFn)

Array.prototype.splice()

Add, remove, or replace elements in an array at any position. Modifies the original array and returns the deleted elements.

splice(start[, deleteCount[, item1, item2, ...]])

Array.prototype.toReversed()

Return a new array with the elements in reversed order, leaving the original array unchanged.

toReversed()

Array.prototype.toSorted()

Return a new array with the elements sorted, leaving the original array unchanged.

toSorted(compareFn)

Array.prototype.toSpliced()

Return a new array with elements removed or replaced, leaving the original array unchanged.

toSpliced(start, deleteCount, ...items)

Array.prototype.toString()

Returns a string representation of an array, with all elements converted to strings and joined by commas.

toString()

Array.prototype.unshift()

Add one or more elements to the beginning of an array. Returns the new length.

unshift(...items)

Array.prototype.values()

Return a new Array Iterator object that contains the values for each index in the array. Learn how values() enables iteration with for...of loops and the nex...

values()

Array.prototype.with()

Return a new array with the element at the given index replaced with the given value, without mutating the original.

with(index, value)