Array API Reference
JavaScript Array methods for transforming, searching and mutating arrays.
Array
Ordered list of values, zero-indexed, dynamically sized.
arr.map(callback, thisArg?)Return a new array with the result of calling callback on every element.
Returns: Array
arr.filter(callback, thisArg?)Return a new array with all elements for which callback returns truthy.
Returns: Array
arr.reduce(callback, initialValue?)Apply callback against an accumulator and each element to reduce to a single value.
Returns: any
arr.forEach(callback, thisArg?)Execute callback once for each element. Returns undefined.
Returns: undefined
arr.find(callback, thisArg?)Return the first element for which callback returns truthy, or undefined.
Returns: any
arr.some(callback, thisArg?)Return true if at least one element satisfies the predicate.
Returns: boolean
arr.every(callback, thisArg?)Return true if all elements satisfy the predicate.
Returns: boolean
arr.includes(searchElement, fromIndex?)Return true if the array contains searchElement.
Returns: boolean
arr.indexOf(searchElement, fromIndex?)Return the first index of searchElement, or -1 if not found.
Returns: number
arr.slice(start?, end?)Return a shallow copy of a portion of the array from start to end (end excluded).
Returns: Array
arr.splice(start, deleteCount?, ...items)Remove, replace or insert elements in place. Returns the removed elements.
Returns: Array
arr.concat(...values)Return a new array that is the concatenation of the array with values.
Returns: Array
arr.sort(compareFn?)Sort the array in place. Without compareFn, elements are sorted as strings by UTF-16 code unit.
Returns: Array
arr.reverse()Reverse the array in place.
Returns: Array
arr.flat(depth?)Return a new array with sub-arrays concatenated up to depth (default 1).
Returns: Array