Clamps a number between a minimum and maximum value.
Ensures that the returned number is not less than min and not more than max.
min
max
The number to clamp
The minimum allowed value
The maximum allowed value
The clamped number.
clamp(5, 1, 10); // 5clamp(0, 1, 10); // 1clamp(15, 1, 10); // 10 Copy
clamp(5, 1, 10); // 5clamp(0, 1, 10); // 1clamp(15, 1, 10); // 10
Clamps a number between a minimum and maximum value.
Ensures that the returned number is not less than
minand not more thanmax.