×

Index

JavaScript Tutorial

JavaScript Examples

CSS Tutorial

CSS Examples

Math.tan() Method with Example in JavaScript

JavaScript | Math.tan() Method: Here, we are going to learn about the tan() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on February 03, 2020

JavaScript | Math.tan() Method

Math.tan() is a function in math library of JavaScript that is used to find the value of tangent of a number and return the value in radians.

Syntax

    Math.tan(x);

Parameters

  • x – It represents the value whose tangent value to be found.

Return Value

The return type of this method is number, it returns the tangent value of the given x.

Values accepted

Integer, floating-point, numeric string.

Invalid values

Non-numeric string, empty variable, empty array all will return NaN (Not a Number).

Browser support

Chrome, Internet asinlorer, Mozilla, Safari, Opera mini.

Example 1: Valid values

console.log(Math.tan(-1));
console.log(Math.tan(3.14));
console.log(Math.tan(0));
console.log(Math.tan("0.65"));

Output

-1.5574077246549023
-0.001592654936407223
0
0.7602043991336763

Example 2: Invalid values

console.log(Math.tan("Javascript"));

Output

NaN

JavaScript Math Object Methods »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.