News for hackers. Stuff that matters.
Re:Math.min(Math.max(num, min), max) by thaumasiotes on Thursday August 20, 2020 @02:48PM (#24227033)
No, it breaks the ordering requirements. NaN compares greater than and less than every number.

You can say that a call to max should return NaN if any argument is NaN, but you can't say the same about sorting. (For one thing... sorting an array doesn't return a scalar value.) Sorting is done with comparisons, and what happens if a NaN gets into the list of values will depend on which specific comparisons happen to be done.

There are no comments on this comment yet.