Math.tanh()
Math.tanh() 靜態方法返回一個數字的雙曲正切值。即,
試一試
console.log(Math.tanh(-1));
// Expected output: -0.7615941559557649
console.log(Math.tanh(0));
// Expected output: 0
console.log(Math.tanh(Infinity));
// Expected output: 1
console.log(Math.tanh(1));
// Expected output: 0.7615941559557649
語法
js
Math.tanh(x)
引數
x-
一個數字。
返回值
x 的雙曲正切值。
描述
因為 tanh() 是 Math 的一個靜態方法,所以你總是將其寫作 Math.tanh(),而不是作為你建立的 Math 物件的函式(Math 不是一個建構函式)。
示例
使用 Math.tanh()
js
Math.tanh(-Infinity); // -1
Math.tanh(-0); // -0
Math.tanh(0); // 0
Math.tanh(1); // 0.7615941559557649
Math.tanh(Infinity); // 1
規範
| 規範 |
|---|
| ECMAScript® 2026 語言規範 # sec-math.tanh |
瀏覽器相容性
載入中…