infinity and NAN In Java Script

infinity is a property of a number. It represents mathematical infinity.
 
Example
 
Var infi= 1e400*1e350;
Var is javascript keyword, infi is a variable name, 1e400 * 1e350 value assigned to infi variable.
 
In the example given below we have used keyword document.write (message ) which is used to print the message or variable value given with it.
 
Example 1
 
<html>

<head>

</head>

<body>

<script type=”text/javascript”>

var infi = 1e300 * 1e300;

document.write(“Value stored in infi is   : “+infi);

</script >

</body> 

</html>

 
Output of this program
 
Value stored in infi is : Infinity
Click here to view result of this program in browser
 
Nan Stands for not a number and is a result of a mathematical operation which do not have any sense. This happens generally when we divide a 0 by 0.
 
Example
 
var k = 0/0 ;
var is JavaScript keyword, k is a variable name, 0/0 value is assigned to variable k.
 
In the example given below we have used keyword document.write (message ) which is used to print the message or variable value given with it.
 
Example 2
 
<html>

<head>

</head>

<body>

<script type=”text/JavaScript”>

var k = 0/0;

document.write(“Value stored in  k  is   : “+k);

</script >

</body>

</html>

 
Output of this program
Value stored in k is : NaN