News for hackers. Stuff that matters.
Re:Math.min(Math.max(num, min), max) by unoti on Thursday August 20, 2020 @10:31AM (#24223657)
[min, num, max].sort()[1]

I really love this! I’m not sure whether to laugh, cry, or applaud, but I love how it makes me feel all those emotions at the same time.

Re:Math.min(Math.max(num, min), max) by city41 on Thursday August 20, 2020 @01:41PM (#24226065)
I also think the fact it doesn't work in JS (due to sort defaulting to alphabetical sort) brings in even more appropriate emotions.
Re:Math.min(Math.max(num, min), max) by sanbor on Thursday August 20, 2020 @05:12PM (#24229046)

    [10, 2, 100].sort()[1] //returns 100