Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  130] [ 6]  / answers: 1 / hits: 37864  / 10 Years ago, mon, march 24, 2014, 12:00:00

  1. Why NaN === false => false, isn't NaN falsy?

  2. Why NaN === NaN => false, but !!NaN === !!NaN => true



I've been racking my brain trying to figure this out.


More From » javascript

 Answers
52

  1. Falsy and being strictly equal to false are very different things, that's why one has a y instead of an e. ;)

  2. NaN is spec'd to never be equal to anything. The second part of your question is comparing false === false, which is funnily enough, true :)



If you really want to know if something is NaN, you can use Object.is(). Running Object.is(NaN, NaN) returns true.


[#71823] Saturday, March 22, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elijahm

Total Points: 674
Total Questions: 124
Total Answers: 79

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
;