Home >>JavaScript Math Reference >JavaScript atan() Method

JavaScript atan() Method

JavaScript atan() Method

JavaScript atan() method is used to return the arctangent value of a given input number. It returns a numeric value between -PI/2 and PI/2 radian as a result.

Syntax:
Math.atan(x)

Parameter Values

Parameter Description
x This is a required parameter. It defines the given input number.

Browser Support

Method Chrome Edge Firefox Safari Opera
atan() Yes Yes Yes Yes Yes
Here is an example of JavaScript atan() method:
<html>
<body>
<p>Click the button to see the Output.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = Math.atan(2);
}
</script>
</body>
</html>
Output:

Click the button to see the Output.

Example 2:
<html>
<body>
<p>Click the button to see the Output.</p>
<button onclick="myFunction1()">Try it</button>
<p id="demo1"></p>
<script>
function myFunction1() {
  document.getElementById("demo1").innerHTML = Math.atan(1);
}
</script>
</body>
</html>
Output:

Click the button to see the Output.


No Sidebar ads