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 |
瀏覽器相容性
載入中…