seems to clamp down your number to be within the set margins, example one:
_.clamp(-10, -5, 5);
// => -5
_.clamp(10, -5, 5);
// => 5
in the first example, the number we want to clamp is
-10. The minimum allowed value is
-5, the max seems to be
-10 gets clamped to
example 2 is the opposite, the number (
10) is higher then the max allowed (5), so gets clamped down to 5.
Seems practical if you want to clamp down on a user input number. Lets say you run a market place website, you want to restrict the maximum price the user could set. then
clamp could help. You simple restrict the max price, without having to throw an error and have the user enter another number.