Why isn't NaN finite?

javascript, nan

Solution

As Dave Newton said, NaN is not a number, and then you have to consider that it isn't finite nor infinite. The same occurs to these:

NaN > 0  // false
NaN < 0  // false

You might want to read these articles:

- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN

- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite

Problem

Testing the `isFinite` function I see that `NaN` is an infinite number (even if it's not a number `:-)`). ``` isFinite(NaN) // returns false ``` What's the logic behind this? Why isn't `NaN` finite?

Original source