clamp source npm
_.clamp(number, [min], max)
Returns a number whose value is limited to the given range specified
by min
and max
.
Arguments
- number (number)
The number whose value is to be limited.
- [min] (number)
The minimum possible value.
- max (number)
The maximum possible value.
Returns (number)
A number in the range [min, max].
Example
_.clamp(-10, -5, 5);
// => -5
_.clamp(10, -5, 5);
// => 5