Math.atanh()
Math.atanh() 静态方法返回一个数字的逆双曲正切值。即,
试一试
console.log(Math.atanh(-1));
// Expected output: -Infinity
console.log(Math.atanh(0));
// Expected output: 0
console.log(Math.atanh(0.5));
// Expected output: 0.549306144334055 (approximately)
console.log(Math.atanh(1));
// Expected output: Infinity
语法
js
Math.atanh(x)
参数
x-
一个介于 -1 和 1 之间的数字(包含两端)。
返回值
x 的逆双曲正切值。如果 x 为 1,则返回 Infinity。如果 x 为 -1,则返回 -Infinity。如果 x 小于 -1 或大于 1,则返回 NaN。
描述
由于 atanh() 是 Math 的静态方法,您总是使用 Math.atanh() 来调用它,而不是作为您创建的 Math 对象的(Math 不是构造函数)。
示例
使用 Math.atanh()
js
Math.atanh(-2); // NaN
Math.atanh(-1); // -Infinity
Math.atanh(-0); // -0
Math.atanh(0); // 0
Math.atanh(0.5); // 0.5493061443340548
Math.atanh(1); // Infinity
Math.atanh(2); // NaN
规范
| 规范 |
|---|
| ECMAScript® 2026 语言规范 # sec-math.atanh |
浏览器兼容性
加载中…