JavaScript Tutorial JavaScript References

JavaScript - Math.tanh() Method



The JavaScript Math.tanh() method returns hyperbolic tangent of a value. The hyperbolic tangent of x is defined as:

tanh

where e is an Euler's number.

Syntax

Math.tanh(x)

Parameters

x Specify the value.

Return Value

Returns the hyperbolic tangent of a value.

Example:

In the example below, Math.tanh() method is used to find out the hyperbolic tangent of a value.

var txt;

txt = "Math.tanh(0) = " + Math.tanh(0) + "<br>";
txt = txt + "Math.tanh(2) = " + Math.tanh(2) + "<br>";
txt = txt + "Math.tanh(4) = " + Math.tanh(4) + "<br>";
txt = txt + "Math.tanh(-2) = " + Math.tanh(-2) + "<br>";
txt = txt + "Math.tanh(-4) = " + Math.tanh(-4) + "<br>";

The output (value of txt) after running above script will be:

Math.tanh(0) = 0
Math.tanh(2) = 0.9640275800758169
Math.tanh(4) = 0.999329299739067
Math.tanh(-2) = -0.9640275800758169
Math.tanh(-4) = -0.999329299739067

❮ JavaScript - Math Object

5