NaN === false
=> false, isn\'t NaN falsy?NaN === NaN
=> false, but !!NaN === !!NaN
=> trueI\'v
This condition:
NaN === false
Is always false
because numbers are not booleans. To test if a value is falsy you can use a ternary expression:
NaN ? "truthy" : "falsy" // falsy
Why NaN === NaN => false
This is explained in MDN; pragmatically speaking, though, two values of which you only know they're not numbers can't logically be the same thing.
... but why is !!NaN === !!NaN => true
This is because casting NaN
into a boolean will make it false
and booleans can be compared as per normal.