Math

Math.tan

Returns the tangent of a number in radians

Syntax

JavaScript
Math.tan(x)

Parameters

ParameterTypeDescription
xnumberAn angle in radians

Return Value

The tangent of x

Examples

Basic Usage
console.log(Math.tan(0)); // 0
console.log(Math.tan(Math.PI / 4)); // ~1
Practical Example
const angle = 45 * (Math.PI / 180);
console.log(Math.tan(angle).toFixed(4)); // '1.0000'
Advanced Usage
function slopeAngle(slope: number) {
  return Math.atan(slope) * (180 / Math.PI);
}
console.log(slopeAngle(1)); // 45

Understanding Math.tan

The Math.tan method in JavaScript returns the tangent of a number in radians. It belongs to the Math object and is one of the most widely used methods for working with math values in modern JavaScript and TypeScript applications.

The method signature is Math.tan(x). It accepts 1 parameter: x. When called, it returns the tangent of x. Understanding when and how to use tan() helps you write more expressive, readable code.

Common use cases for Math.tan include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like math-sin, math-cos, math-atan2, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Math.tan is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Math Methods

Other methods in the Math object

Related Tools

More Math Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.