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 2015年7月.
Math.atanh() 靜態方法回傳一個數字的反雙曲正切值,也就是說,
嘗試一下
console.log(Math.atanh(-1));
// 預期輸出:-Infinity
console.log(Math.atanh(0));
// 預期輸出:0
console.log(Math.atanh(0.5));
// 預期輸出:0.549306144334055 (approximately)
console.log(Math.atanh(1));
// 預期輸出: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
規範
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.atanh> |
瀏覽器相容性
Loading…