/

HTML / CSS / JavaScript Tutorial

JavaScript Math method: atan()

[this page | pdf | back links]

The atan() method (of the Math object) returns the (principal) arctangent of a real number.

 

It has the following syntax with the following parameters:

 

Math.atan(x)

 

Parameter

Required / Optional

Description

x

Required

Input parameter

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,th,tr,td {border: 1px solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr>
<th>Example</th>
<th>Resulting value of <code>x</code></th>
</tr>
<tr>
<td><code id="Example"></code></td>
<td><code id="Result"></code></td>
</tr>
</table>

<script>
var b = -0.2;
document.getElementById("Example").innerHTML =
  'var x = Math.atan(' + b + ')';
document.getElementById("Result").innerHTML = Math.atan(b);
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedJavaScriptMethodMathAtan() {
  var z = 12.5; return !!Math.atan(z);
}


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Numbers and Math


Desktop view | Switch to Mobile