JavaScript TAN

The JavaScript TAN function is a Math function used to calculate the Trigonometry Tangent for the specified expression. The syntax of the JavaScript TAN Function is:


The mathematical formula of the JavaScript Trigonometry Tangent function 

TAN(x) = Length of the Opposite Side / Length of the Adjacent Side

JavaScript TAN Function Example

In this example, We are going to find the JavaScript Tangent values of different data types and display the output

TIP: Please refer JavaScript ATAN Function to find the JavaScript Arc Tangent.

<!DOCTYPE html>
    <title> JavaScript TAN Function </title>
  <h1> JavaScript TAN Function </h1>
  <p id = "Pos"></p>
  <p id = "Neg"></p>
  <p id = "Dec"></p>
  <p id = "Neg_Dec"></p>
  <p id = "Str"></p>
  <p id = "Exp"></p>
  <p id = "Null"></p>
  <p id = "Multi"></p>
    document.getElementById("Pos").innerHTML = Math.tan(20);
    document.getElementById("Neg").innerHTML = Math.tan(-10);
    document.getElementById("Dec").innerHTML = Math.tan(40.45);
    document.getElementById("Neg_Dec").innerHTML = Math.tan(-60.75);
    document.getElementById("Str").innerHTML = Math.tan("JavaScript");
    document.getElementById("Null").innerHTML = Math.tan(null);
    document.getElementById("Multi").innerHTML = Math.tan(25 + 55 - 77);
JavaScript TAN Function

TAN Function on the string value will return NaN

document.getElementById("Str").innerHTML = Math.tan("JavaScript");

JS TAN Math function on Null value returns Zero as output

document.getElementById("Null").innerHTML = Math.tan(null);