mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-09 15:34:05 +08:00
139 lines
7.0 KiB
HTML
139 lines
7.0 KiB
HTML
<article id="wikiArticle">
|
||
<div>
|
||
</div>
|
||
<h2 id="Summary" name="Summary">概述</h2>
|
||
<p><code><strong>Number.NEGATIVE_INFINITY</strong></code> 属性表示负无穷大。</p>
|
||
<p>不用创建一个 <a href="Reference/Global_Objects/Number" title="JavaScript 的 Number 对象是经过封装的能让你处理数字值的对象。Number 对象由 Number() 构造器创建。"><code>Number</code></a> 实例,使用 <code>Number.NEGATIVE_INFINITY</code> 来访问该静态属性。</p>
|
||
<p></p><table class="standard-table">
|
||
<thead>
|
||
<tr>
|
||
<th class="header" colspan="2"><code>Number.NEGATIVE_INFINITY</code> 属性的属性特性:</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>writable</td>
|
||
<td>false</td>
|
||
</tr>
|
||
<tr>
|
||
<td>enumerable</td>
|
||
<td>false</td>
|
||
</tr>
|
||
<tr>
|
||
<td>configurable</td>
|
||
<td>false</td>
|
||
</tr>
|
||
</tbody>
|
||
</table><p></p>
|
||
<h2 id="Description" name="Description">描述</h2>
|
||
<p><code>Number.NEGATIVE_INFINITY</code> 的值和全局对象的 <a href="Reference/Global_Objects/Infinity" title="全局属性 Infinity 是一个数值,表示无穷大。"><code>Infinity</code></a> 属性的负值相同。</p>
|
||
<p>该值的行为同数学上的无穷大(infinity)有一点儿不同:</p>
|
||
<ul>
|
||
<li>任何正值,包括 <code>POSITIVE_INFINITY,</code>乘以 <code>NEGATIVE_INFINITY</code> 为 <code>NEGATIVE_INFINITY</code>。</li>
|
||
<li>任何负值,包括 <code>NEGATIVE_INFINITY</code>,乘以 <code>NEGATIVE_INFINITY</code> 为 <code>POSITIVE_INFINITY</code>。</li>
|
||
<li>0 乘以 <code>NEGATIVE_INFINITY</code> 为 <code>NaN</code>.</li>
|
||
<li>NaN 乘以 <code>NEGATIVE_INFINITY</code> 为<code> NaN</code>.</li>
|
||
<li><code>NEGATIVE_INFINITY</code> 除以任何负值(除了 <code>NEGATIVE_INFINITY)</code>为 <code>POSITIVE_INFINITY</code>。</li>
|
||
<li><code>NEGATIVE_INFINITY</code> 除以任何正值(除了 <code>POSITIVE_INFINITY</code>)为 <code>NEGATIVE_INFINITY</code>。</li>
|
||
<li><code>NEGATIVE_INFINITY</code> 除以 <code>NEGATIVE_INFINITY</code> 或 <code>POSITIVE_INFINITY</code> 是 <code>NaN</code>。</li>
|
||
<li>任何数除以 <code>NEGATIVE_INFINITY</code> 为 0。</li>
|
||
</ul>
|
||
<p>为了成功返回一个有限值,你可能会使用 <code>Number.NEGATIVE_INFINITY</code> 属性来判断是否显示一个条件错误 。然而 <a href="Reference/Global_Objects/isFinite" title="该全局 isFinite() 函数用来判断被传入的参数值是否为一个有限数值(finite number)。在必要情况下,参数会首先转为一个数值。"><code>isFinite</code></a> 方法更适合这种情况。</p>
|
||
<h2 id="Example" name="Example">示例</h2>
|
||
<p>下例中,赋值给变量 <code>smallNumber</code> 一个明显小于 JavaScript 中的最小值的值。当 <code>if</code> 语句执行时,<code>smallNumber</code> 值为 "<code>-Infinity</code>",因此在继续执行代码前,<code>smallNumber</code> 被设为一个更容易管理的值。</p>
|
||
<pre><code class="language-js">var smallNumber = (-Number.MAX_VALUE) * 2
|
||
|
||
if (smallNumber == Number.NEGATIVE_INFINITY) {
|
||
smallNumber = returnFinite();
|
||
}
|
||
</code></pre>
|
||
<h2 id="规范">规范</h2>
|
||
<table class="standard-table">
|
||
<tbody>
|
||
<tr>
|
||
<th scope="col">Specification</th>
|
||
<th scope="col">Status</th>
|
||
<th scope="col">Comment</th>
|
||
</tr>
|
||
<tr>
|
||
<td>ECMAScript 1st Edition. Implemented in JavaScript 1.1</td>
|
||
<td>Standard</td>
|
||
<td>Initial definition.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.3.5" hreflang="en" lang="en" rel="noopener">ECMAScript 5.1 (ECMA-262)<br/><small lang="zh-CN">Number.NEGATIVE_INFINITY</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-number.negative_infinity" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Number.NEGATIVE_INFINITY</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td> </td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h2 id="浏览器规范">浏览器规范</h2>
|
||
<p></p><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
|
||
This compatibility table still uses the old format,
|
||
because we haven't yet converted the data it contains.
|
||
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
|
||
<div class="htab">
|
||
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
|
||
<ul>
|
||
<li class="selected"><a>Desktop</a></li>
|
||
<li><a>Mobile</a></li>
|
||
</ul>
|
||
</div><p></p>
|
||
<div id="compat-desktop">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>Feature</th>
|
||
<th>Chrome</th>
|
||
<th>Firefox (Gecko)</th>
|
||
<th>Internet Explorer</th>
|
||
<th>Opera</th>
|
||
<th>Safari</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="compat-mobile">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>Feature</th>
|
||
<th>Android</th>
|
||
<th>Chrome for Android</th>
|
||
<th>Firefox Mobile (Gecko)</th>
|
||
<th>IE Mobile</th>
|
||
<th>Opera Mobile</th>
|
||
<th>Safari Mobile</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<h2 id="See_also" name="See_also">相关链接</h2>
|
||
<ul>
|
||
<li><a href="Reference/Global_Objects/Number/POSITIVE_INFINITY" title="Number.POSITIVE_INFINITY 属性表示正无穷大。"><code>Number.POSITIVE_INFINITY</code></a></li>
|
||
<li><a href="Reference/Global_Objects/Infinity" title="全局属性 Infinity 是一个数值,表示无穷大。"><code>Infinity</code></a></li>
|
||
<li><a href="Reference/Global_Objects/isFinite" title="该全局 isFinite() 函数用来判断被传入的参数值是否为一个有限数值(finite number)。在必要情况下,参数会首先转为一个数值。"><code>isFinite</code></a></li>
|
||
</ul>
|
||
</article> |