此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Math.cosh()

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

Math.cosh() 函数返回数值的双曲余弦函数,可用 constant e 表示:

Math.cosh(x)=ex+e-x2\mathtt{\operatorname{Math.cosh(x)}} = \frac{e^x + e^{-x}}{2}

语法

Math.cosh(x)

参数

x

数值。

描述

由于 cosh() 是 Math 的静态函数,只需通过 Math.cosh() 调用,而不用通过创建 Math 对象来调用。

示例

使用 Math.cosh()

js
Math.cosh(0); // 1
Math.cosh(1); // 1.5430806348152437
Math.cosh(-1); // 1.5430806348152437

规范

规范
ECMAScript® 2027 Language Specification
# sec-math.cosh

浏览器兼容性

参见