| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since July 2015.
The Math.atan() static method returns the inverse tangent (in radians) of a number, that is
// Calculates angle of a right-angle triangle in radians
function calcAngle(opposite, adjacent) {
return Math.atan(opposite / adjacent);
}
console.log(calcAngle(8, 10));
// Expected output: 0.6747409422235527
console.log(calcAngle(5, 3));
// Expected output: 1.0303768265243125
Math.atan(x)
xA number.
The inverse tangent (angle in radians between -2-\frac{\pi}{2} and 2\frac{\pi}{2}, inclusive) of x. If x is Infinity, it returns 2\frac{\pi}{2}. If x is -Infinity, it returns -2-\frac{\pi}{2}.
Because atan() is a static method of Math, you always use it as Math.atan(), rather than as a method of a Math object you created (Math is not a constructor).
Math.atan(-Infinity); // -1.5707963267948966 (-/2)
Math.atan(-0); // -0
Math.atan(0); // 0
Math.atan(1); // 0.7853981633974483 (/4)
Math.atan(Infinity); // 1.5707963267948966 (/2)
// The angle that the line (0,0) -- (x,y) forms with the x-axis in a Cartesian coordinate system
const theta = (x, y) => Math.atan(y / x);
Note that you may want to avoid the theta function and use Math.atan2() instead, which has a wider range (between - and ) and avoids outputting NaN for cases such as when x is 0.
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-math.atan |
Math.acos()Math.asin()Math.atan2()Math.cos()Math.sin()Math.tan()atan() functionThis page was last modified on Dec 29, 2025 by MDN contributors.
MathYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |