Math.cosh() 函数返回数值的双曲余弦函数, 可用 constant e 表示:
Syntax
Math.cosh(x)
参数
-
x - 数值.
描述
由于cosh() 是Math的静态函数, 只需通过Math.cosh() 调用,而不用通过创建Math对象来调用.
示例
使用 Math.cosh()
Math.cosh(0); // 1 Math.cosh(1); // 1.5430806348152437 Math.cosh(-1); // 1.5430806348152437
Polyfill
可通过 Math.exp() 函数模拟实现:
Math.cosh = Math.cosh || function(x) {
return (Math.exp(x) + Math.exp(-x)) / 2;
}
或只调用一次 Math.exp() 函数:
Math.cosh = Math.cosh || function(x) {
var y = Math.exp(x);
return (y + 1 / y) / 2;
};
规范
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) Math.cosh |
Standard | Initial definition. |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains.
Find out how you can help!
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 38 | 25 (25) | 未实现 | 25 | 7.1 |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | 未实现 | 未实现 | 25.0 (25) | 未实现 | 未实现 | 8 |