The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone
https://github.com/mdn/interactive-examples
and send us a pull request.
描述
Infinity
是特性在
全局对象
。换句话说,它是全局作用域变量。
初始值
Infinity
is
Number.POSITIVE_INFINITY
。值
Infinity
(positive infinity) is greater than any other number.
This value behaves slightly differently than mathematical infinity; see
Number.POSITIVE_INFINITY
了解细节。
As defined by the ECMAScript 5 specification,
Infinity
is read-only (implemented in 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 */
console.log(1 / 0 ); /* Infinity */
规范
浏览器兼容性
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out
https://github.com/mdn/browser-compat-data
and send us a pull request.
更新 GitHub 上的兼容性数据
|
Desktop
|
Mobile
|
Server
|
|
Chrome
|
Edge
|
Firefox
|
Internet Explorer
|
Opera
|
Safari
|
Android webview
|
Chrome for Android
|
Firefox for Android
|
Opera for Android
|
Safari on iOS
|
Samsung Internet
|
Node.js
|
Infinity
|
Chrome
1
|
Edge
12
|
Firefox
1
|
IE
4
|
Opera
4
|
Safari
1
|
WebView Android
1
|
Chrome Android
18
|
Firefox Android
4
|
Opera Android
10.1
|
Safari iOS
1
|
Samsung Internet Android
1.0
|
nodejs
0.1.100
|
图例
-
完整支持
完整支持
另请参阅