By using POSITIVE_INFINITY
property we can return the positive infinity in JavaScript.
<p>Click the below button to return the Positive Infinity in JavaScript.</p> <input type="button" value="POSITIVE_INFINITY" onclick="Function()" /> <p id="myId"></p> <script> function Function() { document.getElementById("myId").innerHTML = Number.POSITIVE_INFINITY; } </script>
In the above code snippet we have given Id
as "myId
"to the second <p>
element in the HTML code, we need to return the positive infinity in JavaScript. For that we are using the code Number.POSITIVE_INFINITY
. There is a Function() in the<script>
block which is connected to the Onclick of the HTML button. The document.getElementById(
"myId")
returns the element that has Id "id=myID" in the HTML page. Onclick of the button "POSITIVE_INFINITY" fires the Function() in the <script>
block at the same time Number.POSITIVE_INFINITY
returns the positive infinity in JavaScript and gives the output as "Infinity".
OUTPUT
NOTE: POSITIVE_INFINITY is consider as higher than any other number.
Views: 3493 | Post Order: 85