JavaScript Math.tan()

Examples

let x = Math.tan(1);
Try it Yourself »
Math.tan(0);
Math.tan(Math.PI);
Try it Yourself »

Math.tan(x) expect x in radians.

To use degrees, convert degrees to radians first.

let radians = degrees * Math.PI/180;
Math.tan(radians);
Try it Yourself »

Description

The Math.tan() method returns the tangent of a number.

The Math.tan() method expects the number in radians.

Based on sine and cosine:
Math.tan(x) = Math.sin(x) / Math.cos(x).


What is Radians?

Radians is an angle's α amount of rotation b on a circle:

Radian
DegreesPIRadians
00
PI/1800.0175
30°PI/60.52
45°PI/40.79
90°PI/21.57
180°PI3.14
360°PI*26.28



Syntax

Math.tan(x)

Parameters

Parameter Description
x Required.
A number representing radians.

Return Value

Type Description
NumberThe tangent of the number.
NaN if the number is empty or not numeric.

The Pythagoran Therorem

Math.sin(), Math.cos(), and Math.tan() are related to the Pythagorean theorem:

Pythagoras

Theorem: c2 = a2 + b2

The sine Math.sin() to the angle is a / c.

The cosine Math.cos() to the angle is b / c.

The tangent Math.tan() to the angle is a / b.



Browser Support

Math.tan() is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.