Math.tanh()
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.tanh() は静的メソッドで、数値のハイパーボリックタンジェントを返します。
試してみましょう
console.log(Math.tanh(-1));
// 予想される結果: -0.7615941559557649
console.log(Math.tanh(0));
// 予想される結果: 0
console.log(Math.tanh(Infinity));
// 予想される結果: 1
console.log(Math.tanh(1));
// 予想される結果: 0.7615941559557649
構文
js
Math.tanh(x)
引数
x-
数値です。
返値
x のハイパーボリックタンジェントです。
解説
tanh() は Math の静的メソッドであるため、生成した Math オブジェクトのメソッドとしてではなく、常に Math.tanh() として使用するようにしてください (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
仕様書
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.tanh> |
ブラウザーの互換性
Loading…