In JavaScript, Math
is a built-in object that contains different methods and properties used to perform mathematical operations. It contains an atan()
function, which is used to compute a specified number’s arc tangent. This is also known as the inverse tangent of a number.
Math.atan(param);
param
: This is a number that represents the tangent value. It is the input value of Number
type for which we want to find the atan()
.
Number
in JavaScript is a 64-bit double-precision value which is the same asdouble
in C# or Java.
Number
: It returns the angle θ whose tangent is equal to the given param
. It is of Number
type. Its range is:
To convert radians to degrees, use the following formula.
- Degrees = Radians × 180 / π
where
π
= 3.14159, approximately.
console.log("atan(-1) = " + Math.atan(-1));console.log("atan(0) = " + Math.atan(0));console.log("atan(1) = " + Math.atan(1));console.log("atan(∞) = " + Math.atan(Infinity));console.log("atan(-∞) = " + Math.atan(-Infinity));