Math.cosh()
Math.cosh() 静态方法返回一个数值的双曲余弦值。即:
试一试
console.log(Math.cosh(0));
// Expected output: 1
console.log(Math.cosh(1));
// Expected output: 1.543080634815244 (approximately)
console.log(Math.cosh(-1));
// Expected output: 1.543080634815244 (approximately)
console.log(Math.cosh(2));
// Expected output: 3.7621956910836314
语法
js
Math.cosh(x)
参数
x-
一个数字。
返回值
计算 x 的双曲余弦值。
描述
因为 cosh() 是 Math 的静态方法,所以你总是通过 Math.cosh() 来使用它,而不是作为一个你创建的 Math 对象的方法(Math 不是一个构造函数)。
示例
使用 Math.cosh()
js
Math.cosh(-Infinity); // Infinity
Math.cosh(-1); // 1.5430806348152437
Math.cosh(-0); // 1
Math.cosh(0); // 1
Math.cosh(1); // 1.5430806348152437
Math.cosh(Infinity); // Infinity
规范
| 规范 |
|---|
| ECMAScript® 2026 语言规范 # sec-math.cosh |
浏览器兼容性
加载中…