rangeRight es-toolkit
Creates an array of numbers in reverse order within a specified range and step.
Usage
rangeRight(end)
Use rangeRight when you need a consecutive array of numbers in reverse order from the end value to 0. It's like range but the result comes from the back.
Parameters
The end value (exclusive). Starts from 0.
Returns
Returns a reverse array of numbers generated from the end value to 0.
rangeRight(start, end, step?)
Use rangeRight when you need a consecutive array of numbers in reverse order with a specified start value, end value, and step. It's like range but the result comes from the back.
Useful when you need reverse order for countdowns or pagination.
Parameters
The start value. Included in the result array.
The end value. Not included in the result array.
The increment between each number. Must be a non-zero integer. Defaults to 1.
Returns
Returns a reverse array of numbers generated with the specified range and step.
Throws
- Throws an error if
stepis 0 or not an integer.
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.