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 July 2015.
TheMath.tanh() static method returns the hyperbolic tangent of a number. That is,
In this article
Try it
console.log(Math.tanh(-1));// Expected output: -0.7615941559557649console.log(Math.tanh(0));// Expected output: 0console.log(Math.tanh(Infinity));// Expected output: 1console.log(Math.tanh(1));// Expected output: 0.7615941559557649Syntax
js
Math.tanh(x)Parameters
xA number.
Return value
The hyperbolic tangent ofx.
Description
Becausetanh() is a static method ofMath, you always use it asMath.tanh(), rather than as a method of aMath object you created (Math is not a constructor).
Examples
>Using Math.tanh()
js
Math.tanh(-Infinity); // -1Math.tanh(-0); // -0Math.tanh(0); // 0Math.tanh(1); // 0.7615941559557649Math.tanh(Infinity); // 1Specifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.tanh> |