Math.min and Math.max
You’ve probably heard of and used the Math.min
and Math.max
functions in JavaScript before, they’re pretty self explanatory.
Something useful
One trick that I found particularly handy, is when using both Math.min
and Math.max
together to constrain a number between two bounds.
Something to take-away
We can use ‘currying’ to create a dynamic constraining function that will constrain numbers to the specified bounds.