How to use tan in JavaScript

In this article, I will explain use of tan() method in JavaScript.
  • 2159

JavaScript tan() Method

  • tan() method of math object is used to get the tangent of a number.

  • In tan() method, numeric value represents the tangent of the angle.

Syntax

Math.tan(x)

  • x is a Required number

Example

In the following example show to tan() method returns the tangent of numbers.

<html>

<head>

</head>

<body>

<h3 style="color:Blue">JavaScript tan() Method Example</h3>

<script type="text/javascript">

    var a = Math.tan(-30);

    document.write("First Test tan Value : " + a);

    var b = Math.tan(90);

    document.write("<br />Second Test tan Value : " + b);

    var c = Math.tan(45);

    document.write("<br />Third Test tan Value : " + c);

    var d = Math.tan(Math.PI / 180);

    document.write("<br />Fourth Test tan Value : " + d);

</script>

</body>

</html>

Output

tan method.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.