JavaScript Math.tan() Method
The Math.tan() static method returns the tangent of an angle given in radians.
Description
The Math.tan() static method returns the tangent of an angle in radians, the ratio of its sine to its cosine.
The tangent becomes extremely large near 90 degrees (π/2 radians), and because π/2 can't be stored exactly, Math.tan(Math.PI / 2) returns a huge number rather than Infinity.
Tangents relate an angle to a slope, which is useful for calculating heights from angles and distances. To go the other way, from a slope or two coordinates to an angle, use Math.atan() or, better, Math.atan2(). Like every member of Math, it's called on the Math object itself rather than on a number, and it only works with the Number type: passing a BigInt throws a TypeError.
Syntax
Math.tan(x)Parameters
- xAn angle in radians.
Return Value
The tangent of the angle.
Example
Browser Support
The following information will show you the current browser support for the Math.tan() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





