Skip to main content

clamp

_.clamp(lower, upper, number) # Ⓢ [Ⓣ][1] Ⓝ

Clamps number within the inclusive lower and upper bounds.

Since​

4.0.0

Arguments​

  1. lower (number): The lower bound.
  2. upper (number): The upper bound.
  3. number (number): The number to clamp.

Returns​

(number): Returns the clamped number.

Example​

_.clamp(-5, 5, -10);
// => -5

_.clamp(-5, 5, 10);
// => 5