The basic function is simply defined as:
function clamp(num, min, max) {
return Math.max(min, Math.min(num, max));
}
That is, if you don't try to do anything fancy and make any parameters optional. Lodash does and it makes the implementation much more complex. _.clamp(input: number, lower?: number, upper: number): number;
https://github.com/lodash/lodash/blob/ddfd9b11a0126db2302cb7...