random es-toolkit
Generates a random number within a specified range. The number can include decimals.
Usage
random(maximum) / random(minimum, maximum)
Use random when you need a random number. It generates numbers with decimal points.
Throws an error if the range is invalid.
Parameters
maximumnumberrequired
The maximum value (exclusive) when using a single parameter. Must be greater than 0.
minimumnumberrequired
The minimum value (inclusive).
maximumnumberrequired
The maximum value (exclusive). Must be greater than the minimum value.
Returns
Returns a random decimal within the specified range.
Throws
Throws an error if the maximum value is less than or equal to the minimum value.
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.