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 ?
<script>
var a = 'xyz';
document.write(a*2); // Output NaN
</script>

Not equal to itself

NaN is the only JavaScript value which is not equal to itself.
<script>
var a = NaN;
if(a === a){
document.write('Equal')	
}else{
document.write('Not Equal')		
}
</script>
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


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    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 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer