Javascript Reference - JavaScript POSITIVE_INFINITY Property








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:





Browser Support

POSITIVE_INFINITY Yes Yes Yes Yes Yes

Syntax

Number.POSITIVE_INFINITY;

Return Value

The numeric value: Infinity.

Example

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:





Example 2

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: