aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html
blob: 929985516d327733f06863bce0978190cce4ba32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: Infinity
slug: Web/JavaScript/Reference/Global_Objects/Infinity
tags:
  - JavaScript
translation_of: Web/JavaScript/Reference/Global_Objects/Infinity
---
<div>{{jsSidebar("Objects")}}</div>

<p>全局属性 <code><strong>Infinity</strong></code> 是一个数值,表示无穷大。</p>

<p>{{js_property_attributes(0,0,0)}}</p>

<p>{{EmbedInteractiveExample("pages/js/globalprops-infinity.html")}}</p>

<h2 id="Description" name="Description">描述</h2>

<p><code>Infinity</code><em>全局对象</em><em>global object</em>)的一个属性,即它是一个全局变量。</p>

<p><code>Infinity</code> 的初始值是 {{jsxref("Number.POSITIVE_INFINITY")}}<code>Infinity</code>(正无穷大)大于任何值。</p>

<p>该值的意义与数学无穷大略有不同。 有关详细信息,请参见{{jsxref("Number.POSITIVE_INFINITY")}}</p>

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

<h2 id="示例">示例</h2>

<pre class="brush: js line-numbers  language-js">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 */</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">规范</th>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-value-properties-of-the-global-object-infinity', 'Infinity')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{Compat("javascript.builtins.Infinity")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{jsxref("Number.NEGATIVE_INFINITY")}}</li>
 <li>{{jsxref("Number.POSITIVE_INFINITY")}}</li>
 <li>{{jsxref("Number.isFinite")}}</li>
</ul>