Math tan() Method - Javascript Math

Javascript examples for Math:tan

Description

The tan() method returns the tangent of an angle.

Parameter Values

Parameter Description
x Required. A number representing an angle (in radians)

Return Value:

A Number, representing the tangent of an angle

The following code shows how to return the tangent of a number (angle):

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w  w w . j  a v a  2 s  .co m*/
    var a = Math.tan(90);
    var b = Math.tan(-90);
    var c = Math.tan(45);
    var d = Math.tan(60);

    var x = a + "<br>" + b + "<br>" + c + "<br>" + d;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials