JavaScript Tutorial JavaScript References

JavaScript - Math.tan() Method



The JavaScript Math.tan() method returns trigonometric tangent of an angle (angle should be in radians). In the graph below, tan(x) vs x is plotted.

Tan Function

Syntax

Math.tan(x)

Parameters

x Specify the angle in radian.

Return Value

Returns the trigonometric tangent of an angle.

Example:

In the example below, Math.tan() method is used to find out the trigonometric tangent of an angle.

//Math.PI - value of PI from Math object
var pi = Math.PI;
var txt;

txt = "Math.tan(pi/6) = " + Math.tan(pi/6) + "<br>";
txt = txt + "Math.tan(pi/4) = " + Math.tan(pi/4) + "<br>";
txt = txt + "Math.tan(pi/3) = " + Math.tan(pi/3) + "<br>";

The output (value of txt) after running above script will be:

Math.tan(pi/6) = 0.5773502691896257
Math.tan(pi/4) = 0.9999999999999999
Math.tan(pi/3) = 1.7320508075688767

❮ JavaScript - Math Object