Home »
        JavaScript
    
    NaN property with example in JavaScript
    
    
    
    
        JavaScript NaN property: Here, we are going to learn about the NaN property with the example in JavaScript.
        
            Submitted by IncludeHelp, on February 02, 2019
        
    
    
    NaN property
    "NaN" stands for "Not-a-Number"; it is a global property in JavaScript which is used for the number which is not a legal i.e. it indicates that the value is not a legal number.
    
    Example
    In this example, we have two variables, num1 which is assigned by 10 which is a legal number and num2 is assigned by parsing the value of "Hello" as an integer it returns an illegal number.
<html>
<head>
<title>JavaScipt Example</title>
</head>
<body>
	<script>
		var num1 = 10;
		var num2 = parseInt("Hello");
		
		//printing the values
		document.write("num1: " + num1 + "<br>");
		document.write("num2: " + num2 + "<br>");		
	</script>
</body>
</html>
Output
num1: 10
num2: NaN
	JavaScript Built-in Functions »
	
	
    
    
    
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement