When JavaScript makes no sense
July 28th, 2010Here are some of the more weird things I’ve found over the years when using JavaScript.
My most favorite quirk ever is:
typeof NaN // => number
Recently, I stumbled upon the “magic increasing number”:
9999999999999999 // => 10000000000000000
And this is from my article on number parsing:
parseInt("01") // --> 1 parseInt("02") // --> 2 parseInt("07") // --> 7 parseInt("08") // --> 0 parseInt("09") // --> 0
There’s an extensive collection of these and more at wtfjs, so go check it out! Some are pretty obvious in hindsight, but some are really, really obscure.
If you think you know everything about JavaScript, you probably don’t… What’s your favorite JavaScript quirk?
Tweet