Favorites

JavaScript Math.tan() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Math.tan()
JavaScript Math Static methodThis method is supported by all modern browsers.
Updated 28th November 2026

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

console.log(Math.tan(0));
console.log(Math.tan(Math.PI / 4).toFixed(3));

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.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee