Math atan() Method - Javascript Math

Javascript examples for Math:atan

Description

The atan() method returns the arctangent of a number as a value between -PI/2 and PI/2 radians.

Parameter Values

Parameter Description
x Required. A number

Return Value:

A Number, from -PI/2 to PI/2, or NaN if the value is empty

The following code shows how to return the arctangent of a specified number:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {/*  w w  w. ja v a 2 s.c om*/
    document.getElementById("demo").innerHTML = Math.atan2(8, 4);
}
</script>

</body>
</html>

Related Tutorials