3 ms·
Yes, it's goofy that typeof (NaN) == 'number'. But it's not that unreasonable to have a numeric value that's explicitly invalid. Pointers and references in ot
by dap 14y ago
Yes, it's goofy that typeof (NaN) == 'number'. But it's not that unreasonable to have a numeric value that's explicitly invalid. Pointers and references in other languages have null, which is a legal value for any type of object, but is explicitly invalid if used as an object.
Also, isNaN is global.
- SeanLuke 14y ago> Yes, it's goofy that typeof (NaN) == 'number'. You should be harsher on him. NaN is definitely a number in practically every programming language. (type-of (/ 0.0 0.0)) SINGLE-FLOAT System.err.println((new Double(0.0/0.0)) instanceof Number) true from types import * type(1e10000 / 1e10000) <type 'float'> It looks like the blogger is just out and out mistaken. But there's more. The poster goes on about NaN not being easy to check for: not realizing that it's the only value which is never equal to itself. He even thinks this is a bug.
- halbermensch 14y agoOr not goofy, if you think of 'number' as an enum constant denoting that variable's type, rather than its value. In this context, 'NaN' just happens to be another admissible value within the space of "number".