Y
Hacker News
new
|
ask
|
show
|
jobs
by
some-1
5021 days ago
No, the correct way is to use the global function isNaN(x);
1 comments
grayrest
5021 days ago
isNaN will return true for NaN and all values that coerce to it. The equals check will test ONLY for NaN itself:
var x = "a";
isNaN(x); // true
(x === x) === false // false
x = NaN
isNaN(x); // true
(x === x) === false // true
link
var x = "a";
isNaN(x); // true
(x === x) === false // false
x = NaN
isNaN(x); // true
(x === x) === false // true