在线文档教程

Infinity

Infinity

全局属性 Infinity是一个数值,表示无穷大。

| Property attributes of Infinity |

|:----|

| Writable | no |

| Enumerable | no |

| Configurable | no |

语法

Infinity

描述

Infinity 是全局对象(global object)的一个属性,即它是一个全局变量。

在 ECMAScript 5 的规范中, Infinity 是只读的(实现于 JavaScript 1.8.5 / Firefox 4)。

示例

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 */

规范

SpecificationStatusComment
ECMAScript 1st Edition (ECMA-262)StandardInitial definition. Implemented in 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

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)