/

HTML / CSS / JavaScript Tutorial

JavaScript Global property: Infinity

[this page | pdf | back links]

The JavaScript Global Infinity property returns Infinity (i.e. larger than the upper limit of floating point numbers in the JavaScript language. Note: -Infinity arises if the number is negative and exceeds the lower limit of floating point numbers.

 

It has the following syntax:

 

Infinity

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,tr,th,caption {border: thin solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table >
  <tr><th>Global property</th><th>Value returned</th></tr>
  <tr><td>'infinity'</td><td id="x1"></td></tr>
  <tr><td>'not a number'</td><td id="x2"></td></tr>
  <tr><td>'not defined'</td><td id="x3"></td></tr>
</table>

<script id="element">
document.getElementById("x1").innerHTML = Infinity;
document.getElementById("x2").innerHTML = NaN;
document.getElementById("x3").innerHTML = undefined;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile