Comparing NaN in javascript -


this question has answer here:

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

Popular posts from this blog

python 3 IndexError: list index out of range -

android - How to save instance state of selected radiobutton on menu -

IF statement in MySQL trigger -