NaNは厳密等価演算子で比較して判別できる
CSS
body { line-height: 1.5; }
JavaScript
function isStrictNaN(x) {
if(x !== x) {
$("body").append(x + ' is NaN!!!');
}
else {
$("body").append(x + ' is not NaN');
}
$("body").append('<br>');
}
isStrictNaN(1);
isStrictNaN(0);
isStrictNaN(undefined);
isStrictNaN([7]);
isStrictNaN({});
isStrictNaN();
isStrictNaN("str");
isStrictNaN({foo: "bar"});
isStrictNaN(NaN);