Comparing NaN in javascript -
this question has answer here:
- how test nan? [duplicate] 2 answers
in javascript, if multiply string number nan
:
console.log("manas" * 5); // result nan
why following code result in false
instead of true
?
console.log("manas" * 5 == nan) // results false
use isnan
function instead.
console.log(isnan("manas" * 5));
http://www.w3schools.com/jsref/jsref_isnan.asp
nan, not number, special type value used denote unrepresentable value. javascript, nan can cause confusion, starting typeof , way comparison handled.
several operations can lead nan result. because there many ways represent nan, makes sense 1 nan not equal nan.
Comments
Post a Comment