Re:Math.min(Math.max(num, min), max)
by yesbabyyes on Thursday August 20, 2020 @10:57AM
(#24223944)
Good point, for those who need to implement a slick compareFunction for numbers, Math.sign is great:
An entirely different alternative is poor man's match:
[ Parent
| on HN ]
Why sign though? I always write my sorts like this.
.sort((a, b) => a - b)Is there a better way to grab a reference to the subtraction operator?