English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
JavaScript Global Properties/Function
GlobalInfinityThe property is a numerical value representing infinity.
Infinity represents the numerical value of positive infinity.
-Infinity represents the numerical value of negative infinity.
When the number exceeds the upper limit of floating-point numbers (i.e.1.797693134862315E + 308),will display Infinity.
When the number exceeds the lower limit of floating-point numbers that is-1.797693134862316E + 308When-Infinity.
The initial value of Infinity isNumber.POSITIVE_INFINITY.
Infinity
var x = document.getElementById('result'); x.innerHTML = Infinity; // Infinity x.innerHTML = Math.pow(10, 1000); // Infinity x.innerHTML = 1.7976931348623157E+10308; // Infinity x.innerHTML = -1.7976931348623157E+10308; // Negative InfinityTest and See‹/›
All browsers fully support the Infinity property:
Property | |||||
Infinity | Yes | Yes | Yes | Yes | Yes |
Writable: | None |
---|---|
Enumerable: | None |
Configurable: | None |
JavaScript Version: | ECMAScript 1 |
Check if maxNumber is Infinity:
var maxNumber = Math.pow(10, 1000); // Maximum Positive Number if (maxNumber === Infinity) { document.getElementById('result').innerHTML = "We call it infinity!"; }Test and See‹/›