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 Juli 2015.
Die statische Methode Math.tanh() gibt den hyperbolischen Tangens einer Zahl zurück. Das bedeutet,
Probieren Sie es aus
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
Syntax
js
Math.tanh(x)
Parameter
x-
Eine Zahl.
Rückgabewert
Der hyperbolische Tangens von x.
Beschreibung
Da tanh() eine statische Methode von Math ist, verwenden Sie diese immer als Math.tanh() und nicht als Methode eines erstellten Math-Objekts (Math ist kein Konstruktor).
Beispiele
>Verwendung von Math.tanh()
js
Math.tanh(-Infinity); // -1
Math.tanh(-0); // -0
Math.tanh(0); // 0
Math.tanh(1); // 0.7615941559557649
Math.tanh(Infinity); // 1
Spezifikationen
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.tanh> |
Browser-Kompatibilität
Loading…