JavaScript > Number Properties

NEGATIVE_INFINITY Property in JavaScript

How to return negative infinity in JavaScript?

By using NEGATIVE_INFINITY property we can return the negative infinity in JavaScript.

<p>Click the below button to return the Negative Infinity in JavaScript.</p>
<input type="button" value="NEGATIVE_INFINITY" onclick="Function()" />
<p id="myId"></p>

    function Function() {
        document.getElementById("myId").innerHTML = Number.NEGATIVE_INFINITY;

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 negative infinity in JavaScript. For that we are using the code Number.NEGATIVE_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 "NEGATIVE_INFINITY" fires the Function() in the <script> block at the same time Number.NEGATIVE_INFINITY returns the negative infinity in JavaScript and gives the output as "-Infinity".


NOTE: NEGATIVE_INFINTY is considered as lower than any other number.

 Views: 3636 | Post Order: 84

Write for us

Hosting Recommendations