JavaScript Math.atan()
Syntax & Examples
Math.atan() static-method
The Math.atan() method in JavaScript returns the arctangent (inverse tangent) of a number. The method returns a value in radians, which is between -π/2 and π/2 (inclusive).
Syntax of Math.atan()
The syntax of Math.atan() static-method is:
Math.atan(x)This atan() static-method of Math returns the arctangent of x.
Parameters
| Parameter | Optional/Required | Description | 
|---|---|---|
| x | required | A number representing the value for which the arctangent is to be returned. | 
Return Type
Math.atan() returns value of type Number.
✐ Examples
1 Using Math.atan() with a positive number
In JavaScript, we can use the Math.atan() method to get the arctangent of a positive number.
For example,
- We call the Math.atan()method with a positive numberx.
- The arctangent value is returned and stored in the variable result.
- We log resultto the console usingconsole.log()method.
JavaScript Program
const x = 1;
const result = Math.atan(x);
console.log(result);Output
0.7853981633974483
2 Using Math.atan() with zero
In JavaScript, we can use the Math.atan() method to get the arctangent of zero.
For example,
- We call the Math.atan()method with zerox.
- The arctangent value is returned and stored in the variable result.
- We log resultto the console usingconsole.log()method.
JavaScript Program
const x = 0;
const result = Math.atan(x);
console.log(result);Output
0
3 Using Math.atan() with a negative number
In JavaScript, we can use the Math.atan() method to get the arctangent of a negative number.
For example,
- We call the Math.atan()method with a negative numberx.
- The arctangent value is returned and stored in the variable result.
- We log resultto the console usingconsole.log()method.
JavaScript Program
const x = -1;
const result = Math.atan(x);
console.log(result);Output
-0.7853981633974483
Summary
In this JavaScript tutorial, we learned about atan() static-method of Math: the syntax and few working examples with output and detailed explanation for each example.
