Home >>JavaScript Math Reference >JavaScript tanh() Method

JavaScript tanh() Method

JavaScript tanh() Method

JavaScript math.tanh() method is a static method of math and is used to return the hyperbolic tangent of the given number by calculating the value. You can always used as math.tanh (), rather than you created as a method of a math object.

Syntax:
Math.tanh(p)

Parameter Values

Parameter Description
x It required a number

Browser Support

Method Chrome Edge Firefox Safari Opera
tanh() 38 12 25 8 25
Here is an example of JavaScript tanh() Method:
<html>
<body>
<button onclick="myTanh()">Click me</button>
<p id="tanh"></p>
<script>
function myTanh() 
{
  document.getElementById("tanh").innerHTML = Math.tanh(4);
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script>
document.writeln(Math.tanh(-2)+"<br>");
document.writeln(Math.tanh(0)+"<br>");
document.writeln(Math.tanh(0.8)+"<br>");
document.writeln(Math.tanh(4));
</script>
</body>
</html>
Output:

No Sidebar ads