JavaScript tan()Method

Math 对象参考手册JavaScript Math Object

Example

Returns a number representing the tangent of an angle:

Math.tan(90);

Output:

-1.995200412208242

Try it yourself »

Definition and Usage

The tan() method returns a number representing the tangent of an angle.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the tan() method


Syntax

Math.tan(x)

Parameter Values

Parameter Description
x Required. An angle in radians. Multiply the angle by 0.017453293 (2PI/360) to convert it to radians.

Return Value

Type Description
Number The tangent value of the angle

Technical Details

JavaScript Version: 1.0


More Examples

Example

In this example, we will calculate the tangent of different numbers:

var a=Math.tan(90);
var b=Math.tan(-90);
var c=Math.tan(45);
var d=Math.tan(60);

a,b,c, anddOutput:

-1.995200412208242
1.995200412208242
1.6197751905438615
0.320040389379563

Try it yourself »


Math 对象参考手册JavaScript Math Object

Other Extensions