{"id":544,"date":"2013-02-06T10:19:53","date_gmt":"2013-02-06T10:19:53","guid":{"rendered":"http:\/\/www.astick.net\/blog\/?p=544"},"modified":"2013-02-06T10:19:53","modified_gmt":"2013-02-06T10:19:53","slug":"javascript-perversities","status":"publish","type":"post","link":"https:\/\/moononastick.com\/blog\/2013\/02\/javascript-perversities\/","title":{"rendered":"JavaScript perversities"},"content":{"rendered":"<p>Just looking at Douglas Crockford&#8217;s &#8220;<a href=\"http:\/\/shop.oreilly.com\/product\/9780596517748.do\">JavaScript: The Good Parts<\/a>&#8221; once again. One of the definitely Not Good parts is the <code>NaN<\/code> value, supposedly standing for &#8220;Not a Number&#8221;.<\/p>\n<p>Given that, what would you expect from <code>typeof NaN<\/code>? Probably not <code>'number'<\/code>.<\/p>\n<p>Even better:<br \/>\n<code>NaN === NaN<\/code> gives <code>false<\/code><br \/>\n<code>NaN !== NaN<\/code> gives <code>true<\/code><br \/>\n<code>NaN<\/code> is not equal to itself!<\/p>\n<p>And best of all, for some reason <code>NaN<\/code> isn&#8217;t a constant, but a global variable. So if you want to change it to something else (e.g. <code>NaN = 'fishcake'<\/code>) you can. Anyone who does should probably be shot, but the fact that it can be done at all is baffling.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just looking at Douglas Crockford&#8217;s &#8220;JavaScript: The Good Parts&#8221; once again. One of the definitely Not Good parts is the NaN value, supposedly standing for &#8220;Not a Number&#8221;. Given that, what would you expect from typeof NaN? Probably not &#8216;number&#8217;. Even better: NaN === NaN gives false NaN !== NaN gives true NaN is not &hellip; <a href=\"https:\/\/moononastick.com\/blog\/2013\/02\/javascript-perversities\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">JavaScript perversities<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/comments?post=544"}],"version-history":[{"count":0,"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/posts\/544\/revisions"}],"wp:attachment":[{"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/media?parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/categories?post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moononastick.com\/blog\/wp-json\/wp\/v2\/tags?post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}