Infinity
全域 Infinity
屬性是一個表示無窮大的數值。
Property attributes of Infinity |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
語法
Infinity
描述
Infinity
是全域物件屬性,即它是全域範圍內的變數。
Infinity
的初始值是 Number.POSITIVE_INFINITY
(en-US) Infinity
值(正無窮大)值大於其他任何數值。該值在數學上表現為無窮大。例如,任何乘以 Infinity
的正整數都是 Infinity
,除以 Infinity
的任何數都是 0。
按照 ECMAScript 5 規範,在 JavaScript 1.8.5 / Firefox 4 實作的 Infinity
乃唯讀屬性。
範例
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 */
規範
規範 | 狀態 | 註解 |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | 初始定義。在 JavaScript 1.3 實作。 |
ECMAScript 5.1 (ECMA-262) The definition of 'Infinity' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Infinity' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Infinity' in that specification. |
Living Standard |
瀏覽器相容性
BCD tables only load in the browser