Clamping value using Math library JavaScript

You may be never heard about clamping value in JavaScript. Yes correct its because there is nothing built in available in JavaScript to clamp the values.

Here I have shared few options how we can define clamp function with Math library.

Option 1: Readable

Option 2: Compact with readable

Option 3 : More compact code

Enjoy…

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *