JavaScript Infinity Property
Below is the example of the Infinity Property.
- Example:
<script>functiontest() {document.write(-3.645464512375121213E+1203466 +"<br>"+ 3.4548643575312453512345E+1203466);}test();</script> - Output:
-Infinity Infinity
The Infinity Property used to display Infinity when the floating point number’s upper limit is exceeded and -Infinity when the floating point number’s lower limit is exceeded. Here, Infinity denotes Positive Infinity and -Infinity represents Negative Infinity.
Syntax:
floating point no.
Return Value: It returns Infinity to represent Positive Infinity and -Infinity to represent Negative Infinity.
More example code for the above property are as follows:
Program 1:
<!DOCTYPE html><html><head> <style> h1 { color: green; } </style></head> <body> <center> <h1> Geeks </h1> <button onclick="test()"> Press </button> <p> 3.4576917263943217389012348562315E+1203466 is the limit of a Floating Point Number.</p> <h4> Clicking the Press button will showcase the Javascript Infinity Property. </h4> <p id="gfg"></p> <script> function test() { document.getElementById( "gfg").innerHTML = -3.4576917263943217389012348562315E+1203466 + "<br>" + 3.4576917263943217389012348562315E+1203466; } </script> </center></body> </html> |
Output:
Supported Browsers:


