For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/array.md.

Array

adjust
Applies a function to the element at an index and returns a new array.
ascend
Creates an ascending comparator from an accessor function.
at
Gets the elements at specified indices from an array and returns a new array.
cartesianProduct
Computes the Cartesian product of the input arrays.
chunk
Splits an array into smaller arrays of a specified size.
chunkBy
Splits an array into chunks of consecutive elements that share the same key.
combinations
Returns all r-length combinations of elements from the input array.
compact
Returns a new array with falsy values removed.
countBy
Categorizes the elements of an array based on a transformation function result and returns an object with counts.
descend
Creates a descending comparator from an accessor function.
difference
Returns a new array excluding elements from the first array that are in the second array.
differenceBy
Transforms elements of two arrays with a conversion function, computes their difference, and returns a new array.
differenceWith
Computes the difference of two arrays using a custom comparison function and returns a new array.
drop
Returns a new array with the specified number of elements removed from the beginning.
dropRepeats
Removes consecutively repeated elements from an array using strict equality (===).
dropRight
Returns a new array with the specified number of elements removed from the end.
dropRightWhile
Returns a new array with elements removed from the end while a condition is satisfied.
dropWhile
Returns a new array with elements removed from the beginning while a condition is satisfied.
fill
Fills array elements with a specified value.
filterAsync
Filters an array using an async predicate function and returns a new array containing only the elements that satisfy the condition.
flatMap
Transforms each element of an array with a function's return value, then flattens to a specified depth and returns a new array.
flatMapAsync
Transforms each element in an array using an async function and flattens the result by one level to return a new array.
flatMapDeep
Transforms each element of an array with a function's return value, then flattens all depths and returns a new array.
flatten
Returns a new array that is flattened to the specified depth.
flattenDeep
Returns a new array with all depths of a nested array flattened.
forEachAsync
Executes an async function for each element in an array.
forEachRight
Iterates over the elements of an array from right to left, executing a function for each element.
groupBy
Returns a new object with array elements grouped according to a key-generating function.
head
Returns the first element of an array.
initial
Returns a new array containing all elements except the last one.
intersection
Returns a new array containing elements that are commonly included in both arrays.
intersectionBy
Returns a new array containing the intersection of two arrays based on the result of a transformation function.
intersectionWith
Returns a new array containing the intersection of two arrays based on a custom comparison function.
isSubset
Checks if one array is a subset of another array.
isSubsetWith
Checks if one array is a subset of another array based on a custom comparison function.
keyBy
Returns a new object with array elements converted to key-value pairs using a key-generating function.
last
Returns the last element of an array.
mapAsync
Transforms each element in an array using an async function and returns a new array.
maxBy
Returns the element with the maximum value from the array based on the value returned by the transformation function.
minBy
Returns the element with the minimum value from the array based on the value returned by the transformation function.
orderBy
Returns a new array sorted by multiple criteria and sort directions.
partition
Returns a tuple that splits an array into two groups based on a condition.
pull
Removes all specified values from an array.
pullAt
Removes elements at specified indices from an array and returns the removed elements.
reduceAsync
Reduces an array to a single value using an async reducer function.
reduceWhile
Like reduce but stops early when the predicate returns false.
remove
Removes elements from an array based on a condition function and returns the removed elements in a new array.
sample
Returns a randomly selected element from an array.
sampleSize
Returns a new array of randomly selected elements with the specified size.
scan
Like reduce but returns an array of all intermediate accumulator values.
shuffle
Returns a new array with the elements randomly shuffled.
sortBy
Returns a new array sorted in ascending order by the given criteria.
sortWith
Sorts an array using multiple comparators in priority order.
tail
Returns a new array consisting of all elements except the first.
take
Creates a new array by taking the specified number of elements from the beginning of the array.
takeRight
Creates a new array by taking the specified number of elements from the end of the array.
takeRightWhile
Returns a new array by taking elements from the end of the array while the condition function returns true.
takeWhile
Creates a new array by taking elements from the beginning of the array while the condition function returns true.
toFilled
Creates a new array by filling part or all of it with the specified value.
unfold
Builds an array from a seed value using an iterator function.
union
Creates a new array containing all unique elements from two arrays.
unionBy
Creates a new array containing unique elements from two arrays based on values transformed by a specific function.
unionWith
Creates a new array containing unique elements from two arrays based on a custom equality function.
uniq
Returns a new array with duplicate elements removed.
uniqBy
Returns a new array with duplicate elements removed based on values returned by the transformation function.
uniqWith
Returns a new array with duplicate elements removed using a comparison function.
unzip
Unpacks grouped arrays and creates new arrays by gathering elements at the same position.
unzipWith
Unpacks grouped arrays and applies a transformation function to return a new array.
windowed
Returns a new array containing snapshots of each window as a window of specified size slides regularly along the array.
without
Creates a new array excluding specific values from the array.
xor
Creates a new array with elements that exist in only one of two arrays.
xorBy
Creates a new array with elements that exist in only one of two arrays, based on values transformed by a given function.
xorWith
Creates a new array with elements that exist in only one of two arrays using a given comparison function.
zip
Creates an array of tuples by bundling elements at the same index from multiple arrays.
zipObject
Creates a single object from a keys array and a values array.
zipWith
Creates a new array by combining multiple arrays using a custom function.