Math.atan(x) returns the arc tangent (inverse tangent) of a number. It answers: which angle has this tangent? The angle is in radians, between -π/2 and π/2.
Math is built into JavaScript. Call the method directly. It is not a constructor, so never write new Math().
Syntax
Call Math.atan() like this. Start with this line.
JavaScript
Math.atan(x)
Call
What it does
Math.atan(x)
Returns the arc tangent of x, in radians.
Built into JavaScript. Call Math.atan() on the Math object — no import required.
Library declarations
JavaScript
Math.atan(x)
JavaScript
interface Math {
atan(x: number): number;
}
Parameters
Parameter
Description
x
Required. A number. Other values are converted to a number first.
Return Value
Return Value
Description
number
The angle in radians, between -π/2 and π/2. Returns NaN if x cannot be turned into a number.
JavaScript Examples
Example 1 — Basic Use
Any number is allowed. The result is an angle in radians.
Apply atan.Math.atan(0.75) gives the angle in radians.
Convert. Multiply by 180 / Math.PI. The angle is about 36.9 degrees.
Example 3 — Why atan() Loses the Quadrant
Two different points can give the same slope. atan2() can tell them apart.
JavaScript
var a = Math.atan(1 / 1); // point (1, 1)
var b = Math.atan(-1 / -1); // point (-1, -1)
console.log(a === b); // true
var c = Math.atan2(1, 1);
var d = Math.atan2(-1, -1);
console.log(c.toFixed(4)); // 0.7854
console.log(d.toFixed(4)); // -2.3562