News for hackers. Stuff that matters.
Re:NPM – "is-even", 160k weekly downloads by afavour on Tuesday November 16, 2021 @11:54AM (#29242877)
The MDN compatibility data says IsNaN was in node as of 0.10.0, which was released 2013-03-11. NPM says the library was first published 2014-09-21. And the library uses isFinite which was added in the same Node version. So... not really, no.

Anyway, my point wasn't so much that the code is an outrage, more that should anyone stumble across this comment thread they know that there is a much clearer and more obvious way to check for IsNaN than using x-x===0.

Re:NPM – "is-even", 160k weekly downloads by Ajedi32 on Tuesday November 16, 2021 @11:58AM (#29242940)
Sorry, I misunderstood which isNaN you were talking about. The global isNaN has unexpected behavior in certain edge cases[1], so that's probably why the library author chose to avoid it. Number.isNaN doesn't have that behavior, but is not supported in IE.

I agree most people these days should just use Number.isNaN, assuming they don't need to support IE.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...