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

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -