Categories
Web development

JavaScript tan() & tanh() Methods

JavaScript tan() & tanh() Methods

The JavaScript Math.tan() returns the tangent of a number.

Syntax:

Math.tan(number)

Example:

<!DOCTYPE html>
<html>
<body>

<p id="example"></p>

<script>
document.getElementById("example").innerHTML = Math.tan(1);
</script>

</body>
</html>

Output:

The JavaScript Math.tan() returns the tangent of a number:


The JavaScript Math.tanh() returns the hyperbolic tangent of a number.

Syntax:

Math.tanh(number)

Example:

<!DOCTYPE html>
<html>
<body>

<p id="example-1"></p>

<script>
document.getElementById("example-1").innerHTML = Math.tanh(1);
</script>

</body>
</html>

Output:

The JavaScript Math.tanh() returns the hyperbolic tangent of a number:


Note: The JavaScript Math.tanh() is not supported in Internet Explorer.

Enjoy coding!

Read also:

JavaScript Math Object

JavaScript atan(), atan2() & atanh() Methods

JavaScript cos() & cosh() Methods