Javascript Reference - JavaScript NEGATIVE_INFINITY Property








The NEGATIVE_INFINITY property represents negative infinity.

NEGATIVE_INFINITY a static property of the JavaScript Number object.

We can only use it as Number.NEGATIVE_INFINITY.

Browser Support

NEGATIVE_INFINITY Yes Yes Yes Yes Yes

Syntax

Number.NEGATIVE_INFINITY;

Return Value

The numeric value: -Infinity

Example


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--from  w  w w. j  av  a2  s .  c o m-->
<script>
function myFunction() {
    var x = 100;
    document.getElementById("demo").innerHTML = x.NEGATIVE_INFINITY;
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to create a negative infinity.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from   ww w.  ja  va  2 s  . c  o m-->
    var n = (-Number.MAX_VALUE) * 2;
    document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 3

The following code shows how to return negative infinity.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--  w  w w.  j a  va  2s . c o  m-->
    document.getElementById("demo").innerHTML = Number.NEGATIVE_INFINITY;
}
</script>

</body>
</html>

The code above is rendered as follows: