JavaScript Math tan( ) Method

Below is the example of the Math tan() Method.

  • Example:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

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

    chevron_right

    
    

  • Output:
    When  zero is  passed as a parameter: 0

The Math.tan() method 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. The 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: This method accept a single parameter as mentioned above and described below:

  • value which is a number representing an angle in radians.

Returns: The Math.tan() method returns the tangent of the given numbers.



Below example illustrate the Mathe tan() method in JavaScript:

  • Example 1:
    Input : Math.tan(0)
    Output : 0
  • Example 2:
    Input : Math.tan(1)
    Output : 1.557407724654902
  • Example 3:
    Input : Math.tan(Math.PI / 4)
    Output : 0.9999999999999999

More codes for the above method are as follows:
Program 1: When 1 is passed as a parameter.

filter_none

edit
close

play_arrow

link
brightness_4
code

<script type="text/javascript">
    document.write("Result : " + Math.tan(1));
</script>

chevron_right


Output:

Result : 1.557407724654902

Program 2: When PI is passed as a parameter.

filter_none

edit
close

play_arrow

link
brightness_4
code

<script type="text/javascript">
    document.write("Result : " + Math.tan(Math.PI / 4));
</script>

chevron_right


Output:

Result : 0.9999999999999999

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

full-stack-img




My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.