Skip to content

WebDevHubs

  • Home
  • HTML
  • CSS
  • JavaScript
  • Web Technologies
  • Web Templates
  • Toggle search form

JavaScript Math.tan() Method

Posted on February 12, 2025February 12, 2025 By Admin No Comments on JavaScript Math.tan() Method

The Math.tan() method in JavaScript is used to compute the tangent of a given number. The tangent function is one of the most fundamental trigonometric functions, which calculates the ratio of the opposite side to the adjacent side of a right triangle. In the context of the unit circle, it is the ratio of the sine to the cosine of an angle.

Syntax

Math.tan(x);

Parameters

  • x (Required): A number representing the angle in radians. This is the value for which the tangent will be calculated. The value of x can be any valid number, including positive or negative numbers, and can even be 0.

Return Value

The Math.tan() method returns a number that represents the tangent of the input value. The output can be any real number, including:

  • Positive values when the angle is in the range of 0 to π/2 (first quadrant).
  • Negative values when the angle is in the range of π to 3π/2 (third quadrant).
  • The function approaches infinity (∞) at angles where cos⁡(x) is zero, such as π/2, 3π/2, etc.

Special Cases

  • If the input is 0, the result will also be 0.
  • For very large positive or negative input values, the tangent function’s result may approach a very large value or infinity.

Example 1: Basic example to use Math.tan() method.

let result = Math.tan(0);
console.log(result); // Output: 0

Since the tangent of 0 radians is 0, the result is 0.

Example 2: Using a positive angle in Math.tan() method.

let result = Math.tan(Math.PI / 4);
console.log(result); // Output: 1

Example 3: Using a negative angle in Math.tan() method.

let result = Math.tan(-Math.PI / 4);
console.log(result); // Output: -1

Example 4: Angle Leading to Infinity.

let result = Math.tan(Math.PI / 2);
console.log(result); // Output: Infinity

Supported Browsers

BrowserVersion Supported
Chrome1.0+
Firefox3.5+
Safari4.0+
Edge12+
Internet Explorer9+
Opera10.50+
JavaScript, Web Technologies Tags:JavaScript-Math-Method, JavaScript-Method

Post navigation

Previous Post: JavaScript Math.sqrt() Method
Next Post: Lodash _.chunk() Method

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • June 2025
  • May 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024

Categories

  • CSS
  • HTML
  • JavaScript
  • Lodash
  • PHP
  • Python
  • Web Technologies
  • Web Templates

Recent Posts

  • JavaScript Array isArray() Method
  • JavaScript Array forEach() Method
  • JavaScript Array includes() Method
  • JavaScript Array keys() Method
  • JavaScript Array lastIndexOf() Method

Recent Comments

No comments to show.

Copyright © 2025 WebDevHubs.

Powered by PressBook Green WordPress theme