Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Infinity

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

Infinity 属性的属性特性:
writable false
enumerable false
configurable false

语法

Infinity 

描述

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

Infinity 的初始值是 Number.POSITIVE_INFINITYInfinity(正无穷大)大于任何值。该值和数学意义上的无穷大很像,例如任何正值乘以 Infinity 为 Infinity, 任何数值(除了Infinity 和 -Infinity)除以 Infinity 为 0。

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

规范

Specification Status Comment
ECMAScript 1st Edition (ECMA-262) Standard Initial definition. Implemented in JavaScript 1.3
ECMAScript 5.1 (ECMA-262)
Infinity
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
Infinity
Standard  
ECMAScript 2016 Draft (7th Edition, ECMA-262)
Infinity
Draft  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

标签: 
 此页面的贡献者: yenshen, tiansh, SphinxKnight, AlexChao
 最后编辑者: yenshen,