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.
NEGATIVE_INFINITY |
Yes | Yes | Yes | Yes | Yes |
Number.NEGATIVE_INFINITY;
The numeric value: -Infinity
<!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:
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:
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: