3 ms·
this library uses the global isFinite, which actually you could just use instead of the whole function, since it does the string coercion and infinity check for
by jazzyjackson 5y ago
this library uses the global isFinite, which actually you could just use instead of the whole function, since it does the string coercion and infinity check for you.
Check out the compatibility table on MDN, Chrome Firefox and Safari version 1 all support it, so I'm pretty sure isNaN and isFinite were in the original spec.
- Ajedi32 5y agoSee the MDN section on "confusing special case behavior"[1] for why they probably didn't want to use the global version of isNaN. Number.isNaN handles those cases better but is not as widely supported. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN#confusing_special-case_behavior https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- jazzyjackson 5y agoThanks for this, I had forgot that empty strings get coerced to 0... interesting choice.