Die globale Eigenschaft Infinity ist ein numerischer Wert, der die Unendlichkeit repräsentiert.
Property attributes of Infinity |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
Syntax
Infinity
Beschreibung
Infinity ist eine Eigenschaft des globalen Objekts, was bedeutet, dass es eine Variable im globalen Gültigkeitsbereich ist.
Der initiale Wert von Infinity entspricht Number.POSITIVE_INFINITY. Der Wert von Infinity (positiv unendlich) ist größer als alle anderen Nummern. Der Wert entspricht der mathematischen Unendlichkeit. Zum Beispiel ist das Produkt einer positiven Zahl mit Infinity immer Infinity. Jede Division einer Zahl durch Infinity ergibt 0.
In der ECMAScript 5 Spezifikation wurde Infinity als read only Eigenschaft (nur lesender Zugriff) eingestuft. (Dieses wurde in JavaScript 1.8.5 / Firefox 4 implementiert.)
Beispiele
console.log(Infinity); /* Infinity */
console.log(Infinity + 1); /* Infinity */
console.log(Math.pow(10,1000)); /* Infinity */
console.log(Math.log(0)); /* -Infinity */
console.log(1 / Infinity); /* 0 */
Spezifikationen
| Spezifikation | Status | Kommentar |
|---|---|---|
| ECMAScript 1st Edition (ECMA-262) | Standard | Initiale Definition. Implementiert in JavaScript 1.3 |
| ECMAScript 5.1 (ECMA-262) Die Definition von 'Infinity' in dieser Spezifikation. |
Standard | |
| ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Infinity' in dieser Spezifikation. |
Standard | |
| ECMAScript 2017 Draft (ECMA-262) Die Definition von 'Infinity' in dieser Spezifikation. |
Entwurf |
Browserkompatibilität
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) |