Function: constrain()
ts
function constrain(
value,
min,
max
): number;Defined in: math.ts:14
Constrain a number between two limits.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number | Any number |
min | number | Minimal limit for the value |
max | number | Maximal limit for the value |
Returns
number
Example
ts
constrain(999, 0, 50); // => 50
constrain(-999, 0, 50); // => 0