5 ms·
https://github.com/yefremov/isnan https://github.com/yefremov/isnan An entire module for just `return value !== value;`
by daurnimator 4y ago
https://github.com/yefremov/isnan https://github.com/yefremov/isnan
An entire module for just `return value !== value;`
- __s 4y ago& ofc there's https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- jefftk 4y agoWhich wasn't everywhere in 2017, when isnan was created: IE11 didn't (and still doesn't, though it's less relevant) have isNaN() (Not supporting a culture of taking a dependency for this sort of thing, though)
- jaywalk 4y agoJust to be clear, because your comment made no sense to me: what IE11 doesn't support is Number.isNaN(). It definitely does support (and has since IE3) plain isNaN(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isnan#browser_compatibility https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- jefftk 4y agoRegular isNaN is very tricky, and almost never what you want: it first coerces its input to a Number, and then checks if that is NaN: isNaN Number.isNaN ----- ------------ {} true false [true] true false undefined true false "{}" true false
- jaywalk 4y agoBut none of those things you listed are numbers. The isNaN output is exactly what I want in pretty much every case.
- jefftk 4y agoisNaN does not tell you whether something is not a Number either. Applying isNaN to any of these returns false: null, true, false, [], "", "cabbage".
- dr-detroit 4y ago
- _Algernon_ 4y agoI'm gonna create a package for isX() for each x in the set of integers. Please use my packages for all comparisons from now on.
- Izkata 4y agois-thirteen is six years old: https://www.npmjs.com/package/is-thirteen https://www.npmjs.com/package/is-thirteen