dropRight es-toolkit
Returns a new array with the specified number of elements removed from the end.
Usage
dropRight(arr, itemsCount)
Use dropRight when you want to remove some elements from the end of an array. It removes the specified number of elements from the end and returns a new array with the remaining elements.
If you pass a negative number or 0, it returns a new array with the same elements as the original.
Parameters
arrT[]required
The array to remove elements from.
itemsCountnumberrequired
The number of elements to remove from the end of the array.
Returns
A new array with the specified number of elements removed from the end.
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.