takeRight es-toolkit
Creates a new array by taking the specified number of elements from the end of the array.
Usage
takeRight(arr, count?)
Use takeRight when you only need a few elements from the end of an array. If the requested count is greater than the array length, it returns the entire array.
If you request more elements than the array has, it returns the entire array.
If you omit count, it takes only the last element.
Parameters
arrT[]required
The array to take elements from.
countnumberoptional
The number of elements to take. Default is 1.
Returns
Returns a new array containing the last count elements from the array.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.