Tutorialspoint.dev

Math.tan( ) In JavaScript

The Math.tan() function in Javascript is used to return the tangent of a number.
The Math.tan() method returns a numeric value that represents the tangent of the angle.
tan() is a static method of Math, therefore, it is always used as Math.tan(), rather than as a method of a Math object created.

Syntax:

Math.tan(value)

Parameters Used:
Value:A number representing an angle in radians.

Return Value:
The Math.tan() function returns the tangent of the given numbers.

Examples:



Input : Math.tan(0)
Output : 0
     
Input : Math.tan(1)
Output : 1.557407724654902

Input : Math.tan(Math.PI / 4)
Output : 0.9999999999999999
  1. When zero is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.tan(0));
    </script>

    Output:

    Output : 0
  2. When 1 is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.tan(1));
    </script>

    Output:

    Output : 1.557407724654902
  3. When PI is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.tan(Math.PI / 4));
    </script>

    Output:

    Output : 0.9999999999999999


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter