_.clamp

_.clamp(number, [lower], upper)

Clamps number within the inclusive lower and upper bounds.

Since

4.0.0

Arguments

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

Returns

(number): Returns the clamped number.

Example

_.clamp(-10, -5, 5);
// => -5
 
_.clamp(10, -5, 5);
// => 5
doc_Lodash
2016-11-27 16:35:50
Comments
Leave a Comment

Please login to continue.