mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-09 07:24:04 +08:00
114 lines
4.3 KiB
HTML
114 lines
4.3 KiB
HTML
<article id="wikiArticle">
|
||
<div></div>
|
||
<h2 id="Summary" name="Summary">概述</h2>
|
||
<p><code><strong>Math.cbrt()</strong></code> 函数返回任意数字的立方根.</p>
|
||
<h2 id="Syntax" name="Syntax">语法</h2>
|
||
<pre><code class="language-javascript">Math.cbrt(<em>x</em>)</code></pre>
|
||
<h3 id="Parameters" name="Parameters">参数</h3>
|
||
<dl>
|
||
<dt><code>x</code></dt>
|
||
<dd>任意数字.</dd>
|
||
</dl>
|
||
<h2 id="Description" name="Description">描述</h2>
|
||
<p>该方法为Math的静态方法,因此请直接通过Math.cbrt()方式调用.</p>
|
||
<p>参数 <code>x</code> 会被自动类型转换成 <code>number </code>类型.</p>
|
||
<p><span style="font-family: 'Courier New','Andale Mono',monospace; font-weight: inherit; line-height: normal;">cbrt 是 "cube root" 的缩写, 意思是立方根.</span></p>
|
||
<h2 id="Examples" name="Examples">示例</h2>
|
||
<pre><code class="language-javascript">Math.cbrt(NaN); // NaN
|
||
Math.cbrt(-1); // -1
|
||
Math.cbrt(-0); // -0
|
||
Math.cbrt(-Infinity); // -Infinity
|
||
Math.cbrt(0); // 0
|
||
Math.cbrt(1); // 1
|
||
Math.cbrt(Infinity); // Infinity
|
||
Math.cbrt(null); // 0
|
||
Math.cbrt(2); // 1.2599210498948734</code></pre>
|
||
<h2 id="Polyfill"><font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">Polyfill</span></font></h2>
|
||
<p>为了与旧版浏览器兼容, 可使用下方函数模拟cbrt():</p>
|
||
<pre><code class="language-js" dir="rtl">if (!Math.cbrt) {
|
||
Math.cbrt = function(x) {
|
||
var y = Math.pow(Math.abs(x), 1/3);
|
||
return x < 0 ? -y : y;
|
||
};
|
||
}</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><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-math.cbrt" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Math.cbrt</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td>Initial definition.</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: #f00;">未实现</span></td>
|
||
<td><a href="/en-US/Firefox/Releases/25" title="Released on 2013-10-29.">25</a> (25)</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</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: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td>25.0 (25)</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<p> </p>
|
||
<h2 id="另请参见">另请参见</h2>
|
||
<ul>
|
||
<li><a href="Reference/Global_Objects/Math/pow" title="Math.pow() 函数返回基数(base)的指数(exponent)次幂,即 baseexponent。"><code>Math.pow()</code></a></li>
|
||
<li><a href="Reference/Global_Objects/Math/sqrt" title="Math.sqrt() 函数返回一个数的平方根,即:"><code>Math.sqrt()</code></a></li>
|
||
</ul>
|
||
<p> </p>
|
||
</article> |