News for hackers. Stuff that matters.
Re:JavaScript - "typeof" operator & null by pcwalton on Friday June 22, 2012 @12:18AM (#4145376)
The other gotcha with "typeof": "typeof NaN" is "number", amusingly enough.
Re:JavaScript - "typeof" operator & null by krisk on Friday June 22, 2012 @12:36AM (#4145422)
Indeed. That's because ECMAScript standard states that Numbers should be IEEE-754 floating point data, which includes positive and negative infinity, and also NaN. Hence why, in JS, it's part of the Number object: Number.NaN. Technically, it's stil a numeric data type, but just points to an invalid number :)
Re:JavaScript - "typeof" operator & null by krisk on Wednesday June 27, 2012 @01:28PM (#4168026)
I've written another post which explores NaN in detail: "NaN and typeof" - http://kiro.me/blog/typeof_nan.html
Re:JavaScript - "typeof" operator & null by crazygringo on Friday June 22, 2012 @10:38AM (#4146902)
My biggest WTF was when I discovered that parseFloat("Infinity") returns... Infinity itself.

I was working on a site that dealt with English dictionaries, and had a field where you could enter either an English word, OR a number with decimals that represented its frequency. And one day I actually typed in "Infinity" as a test word, and program execution went down a completely unexpected code path... Probably the most surprised I've ever been by a bug.