Javascript - Math atan2() Method

The atan2() method returns the arctangent of the quotient of its arguments, between PI and -PI radians.

Description

The atan2() method returns the arctangent of the quotient of its arguments, between PI and -PI radians.

With atan2(), the y coordinate is passed as the first argument and the x coordinate is passed as the second argument.

Syntax

Math.atan2(y, x)
Parameter RequireDescription
y Required. A number representing the y coordinate
x Required. A number representing the x coordinate

Return

A Number, from PI to -PI, or NaN if the value(s) are empty

Example

Demo

//display the arctangent of 8/4
console.log(Math.atan2(8, 4));

Result