全域 Infinity 屬性是一個表示無窮大的數值。

Property attributes of Infinity
Writable no
Enumerable no
Configurable no

語法

Infinity 

描述

Infinity 是全域物件屬性,即它是全域範圍內的變數。

Infinity 的初始值是 Number.POSITIVE_INFINITY 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 Latest Draft (ECMA-262)
The definition of 'Infinity' in that specification.
Draft  

瀏覽器相容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic supportChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes

Legend

Full support  
Full support

參見

文件標籤與貢獻者

此頁面的貢獻者: iigmir, tooto1985, jackblackevo
最近更新: iigmir,