Javascript Reference - JavaScript Infinity Property








Infinity is a numeric value that represents positive infinity.

-Infinity is a numeric value that represents negative infinity.

Browser Support

Infinity Yes Yes Yes Yes Yes

Example

The following code shows how to display a number that exceeds the limit of a floating point number.


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

</body>
</html>

The code above is rendered as follows: