Comment

Comment by zastavka

`isNaN` as it currently exists isn't terribly useful, because anything that can be type-coerced to NaN will return true. If you want to check if something actually is NaN in JS, the common idiom is to test x !== x, since NaN is the only value in JS that is defined as not being equal to itself (don't blame Eich, blame the IEEE floating-point standard). NaN, despite the name, is a "number" that's a result of floating-point calculations with undefined behavior. Sometimes that's a useful thing to test for.

Adding a new, proper isNaN function under a new namespace (Number) lets them do that without breaking the old functionality.

parent zastavka 11 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton