mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-09 07:24:04 +08:00
113 lines
5.8 KiB
HTML
113 lines
5.8 KiB
HTML
<article id="wikiArticle">
|
||
<div></div>
|
||
<p><strong><code>Math.cosh()</code></strong> 函数返回数值的双曲余弦函数, 可用 <a href="Reference/Global_Objects/Math/E" title="Math.E 属性表示自然对数的底数(或称为基数),e,约等于 2.718。">constant e</a> 表示:</p>
|
||
<p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mo lspace="0em" rspace="thinmathspace">Math.cosh(x)</mo></mstyle><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mi>x</mi></msup><mo>+</mo><msup><mi>e</mi><mrow><mo>-</mo><mi>x</mi></mrow></msup></mrow><mn>2</mn></mfrac></mrow><annotation encoding="TeX">\mathtt{\operatorname{Math.cosh(x)}} = \frac{e^x + e^{-x}}{2}</annotation></semantics></math></p>
|
||
<h2 id="Syntax">Syntax</h2>
|
||
<pre><code class="language-javascript"><code>Math.cosh(<var>x</var>)</code></code></pre>
|
||
<h3 id="参数">参数</h3>
|
||
<dl>
|
||
<dt><code>x</code></dt>
|
||
<dd>数值.</dd>
|
||
</dl>
|
||
<h2 id="描述">描述</h2>
|
||
<p>由于<code>cosh()</code> 是Math的静态函数, 只需通过<code>Math.cosh() </code>调用,而不用通过创建Math对象来调用.</p>
|
||
<h2 id="示例">示例</h2>
|
||
<h3 id="使用_Math.cosh()">使用 <code>Math.cosh()</code></h3>
|
||
<pre><code class="language-javascript">Math.cosh(0); // 1
|
||
Math.cosh(1); // 1.5430806348152437
|
||
Math.cosh(-1); // 1.5430806348152437
|
||
</code></pre>
|
||
<h2 id="Polyfill">Polyfill</h2>
|
||
<p>可通过 <a href="Reference/Global_Objects/Math/exp" title="Math.exp() 函数返回 ex,x 表示参数,e 是欧拉常数(Euler's constant),自然对数的底数。"><code>Math.exp()</code></a> 函数模拟实现:</p>
|
||
<pre><code class="language-javascript">Math.cosh = Math.cosh || function(x) {
|
||
return (Math.exp(x) + Math.exp(-x)) / 2;
|
||
}
|
||
</code></pre>
|
||
<p>或只调用一次 <a href="Reference/Global_Objects/Math/exp" title="Math.exp() 函数返回 ex,x 表示参数,e 是欧拉常数(Euler's constant),自然对数的底数。"><code>Math.exp()</code></a> 函数:</p>
|
||
<pre><code class="language-javascript">Math.cosh = Math.cosh || function(x) {
|
||
var y = Math.exp(x);
|
||
return (y + 1 / y) / 2;
|
||
};
|
||
</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.cosh" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Math.cosh</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td>Initial definition.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h2 id="浏览器兼容性">浏览器兼容性</h2>
|
||
<div><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></div>
|
||
<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>38</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>25</td>
|
||
<td>7.1</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>8</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<h2 id="相关链接">相关链接</h2>
|
||
<ul>
|
||
<li><a class="new" href="Reference/Global_Objects/Math/acosh" rel="nofollow" title="此页面仍未被本地化, 期待您的翻译!"><code>Math.acosh()</code></a> <span title="这是一个实验性的 API,请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></li>
|
||
<li><a href="Reference/Global_Objects/Math/asinh" title="Math.asinh() 函数返回给定数字的反双曲正弦值, 即:"><code>Math.asinh()</code></a> <span title="这是一个实验性的 API,请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></li>
|
||
<li><a href="Reference/Global_Objects/Math/atanh" title="Math.atanh() 函数返回一个数值反双曲正切值, 即:"><code>Math.atanh()</code></a> <span title="这是一个实验性的 API,请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></li>
|
||
<li><a href="Reference/Global_Objects/Math/sinh" title="Math.sinh() 函数返回一个数字(单位为角度)的双曲正弦值."><code>Math.sinh()</code></a> <span title="这是一个实验性的 API,请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></li>
|
||
<li><a href="Reference/Global_Objects/Math/tanh" title="Math.tanh() 函数将会返回一个数的双曲正切函数值,计算如下:"><code>Math.tanh()</code></a> <span title="这是一个实验性的 API,请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></li>
|
||
</ul>
|
||
</article> |