Math.acosh()
Math.acosh() 函数返回一个数的反双曲余弦值,即:
尝试一下
语法
js
Math.acosh(x)
参数
x-
一个数字。
返回值
返回给定数的反双曲余弦值,如果该数小于 1 则返回 NaN。
描述
因为 acosh() 是 Math 的静态方法,所以你应该通过 Math.acosh() 调用,而不是作为你创建的 Math 对象的方法(Math 不是构造函数)。
示例
使用 Math.acosh()
js
Math.acosh(-1); // NaN
Math.acosh(0); // NaN
Math.acosh(0.5); // NaN
Math.acosh(1); // 0
Math.acosh(2); // 1.3169578969248166
当参数小于 1 时,Math.acosh() 将返回 NaN。
向下兼容
当 时,都有 ,因此可以使用以下函数实现:
js
Math.acosh = Math.acosh || function(x) {
return Math.log(x + Math.sqrt(x * x - 1));
};
规范
| Specification |
|---|
| ECMAScript Language Specification # sec-math.acosh |
浏览器兼容性
BCD tables only load in the browser