forEachRight es-toolkit
Iterates over the elements of an array from right to left, executing a function for each element.
Usage
forEachRight(arr, callback)
Use forEachRight when you want to traverse an array in reverse order and perform an operation on each element. It calls the callback function sequentially from the last element to the first element of the array. This is useful when you need reverse processing or when you need to work from the end of the array.
The callback function receives three parameters.
Parameters
arrT[]required
The array to iterate over.
callback(value: T, index: number, arr: T[]) => voidrequired
The function to be executed for each element.
value: The current array element being processed.index: The index of the current element being processed.arr: The array that theforEachRightfunction was called upon.
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.