NaN : Not A Number

NaN is known as Not A Number

It is a returned value
It is not configurable and not writable.

Example of NaN

When we will get output as NaN ?
var a = 'xyz';
document.write(a*2); // Output NaN

Not equal to itself

NaN is the only JavaScript value which is not equal to itself.
var a = NaN;
if(a === a){
document.write('Not Equal')		
The output will be Not Equal
To check the value is NaN, we can use isNaN
User entered data from an input text box is always a string, so for any mathematical calculation we need to convert them to number by using parseFlot or parseInt. Otherwise we will get NaN as output of any mathematical calculation if we use directly these inputs.
String to Number by parseInt
JavaScript Math Reference
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer