Java Reference
In-Depth Information
<< false
null === undefined;
<< false
As you can see, hard equality reports that the variable answer is the number 5, but not the
string "5". It also correctly reports that null and undefined are two different values.
Note: When is Not a Number not Not a Number?
The only strange result produced by hard equality is this:
NaN === Nan;
<< false
NaN is the only value in JavaScript that is not equal to itself. To deal with
this, there is a special function called isNaN to test it:
isNaN(NaN);
<< true
isNaN(5);
<< false
Unfortunately, this doesn't always work properly, as can be seen in this ex-
ample:
isNaN("hello");
<< true
This is because the function first of all tries to convert the string to a number,
and strings without numerals are converted to NaN:
Number("hello");
<< NaN
Search WWH ::




Custom Search