Infinity-2

 

In this example, we will show both the infinity values using Number.POSITIVE_INFINITY and Number.NEGATIVE_INFINITY, Which will print "infinity" and "-infinity" in the p tag.

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <p>Click the button to display positive and negative infinity.</p> <button onclick="infinity()">Click it</button> <p id="sample"></p> <script> function infinity() { document.getElementById("sample").innerHTML = Number.POSITIVE_INFINITY +"<br/>" + Number.NEGATIVE_INFINITY; } </script> </body> </html>
Output