# Using Math atan2() function to coding in Javascript/JS

This JavaScript tutorial explains how to use the math characteristic called atan2() with syntax and examples.

## Description

In JavaScript, atan2() is a feature that is used to return the arc tangent (in radians) of (x,y) coordinates. Because the atan2() function is a static feature of the Math object, it have to be invoked thru the placeholder object known as Math.

## Syntax

In JavaScript, the syntax for the atan2() characteristic is:

``Math.atan2(y,x);``

Parameters or Arguments

y The y-coordinate of a point. x The x-coordinate of a point.

## Returns

The atan2() characteristic returns the arc tangent of (x,y) coordinates and the end result is expressed in radians.

## Note

Math is a placeholder object that incorporates mathematical functions and constants of which atan2() is one of these functions.

## Example

Let’s take a appear at an example of how to use the atan2() characteristic in JavaScript.

For example:

``````console.log(Math.atan2(8,1));
console.log(Math.atan2(0,-9));``````

In this example, we have invoked the atan2() characteristic the usage of the Math class.

We have written the output of the atan2() function to the web browser console log, for demonstration purposes, to exhibit what the atan2() characteristic returns.

The following will be output to the internet browser console log:

``````1.446441332248135
3.141592653589793``````

In this example, the first output to the console log again 1.446441332248135 which is the arc tangent of the (x,y) coordinate the place 8 is the y-coordinate and 1 is the x-coordinate.

The 2d output to the console log back 3.141592653589793 which is the arc tangent of the (x,y) coordinate the place 0 is the y-coordinate and -9 is the x-coordinate.

The end result from the atan2() feature is expressed in radians.