Math.atanh()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
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 之間的數字(包含邊界)。
回傳值
描述
由於 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
規範
Specification |
---|
ECMAScript® 2025 Language Specification # sec-math.atanh |