The POSITIVE_INFINITY
property represents positive infinity.
POSITIVE_INFINITY a static property of the JavaScript Number object.
We can only use it as Number.POSITIVE_INFINITY.
<!DOCTYPE html>
<html>
<body>
<!-- w w w. ja v a 2 s . c o m-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = 100;
document.getElementById("demo").innerHTML = x.POSITIVE_INFINITY;
}
</script>
</body>
</html>
The code above is rendered as follows:
POSITIVE_INFINITY |
Yes | Yes | Yes | Yes | Yes |
Number.POSITIVE_INFINITY;
The numeric value: Infinity.
The following code shows how to return positive infinity.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w ww .j a va 2s .co m-->
document.getElementById("demo").innerHTML = Number.POSITIVE_INFINITY;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to create a positive infinity.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--from w ww . j a v a 2 s .co m-->
<script>
function myFunction() {
var n = (Number.MAX_VALUE) * 2;
document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
The code above is rendered as follows: