# How to Convert Degrees to Radians in JavaScript

08/01/2021

Contents

## Converting degrees to radians in JavaScript

Radians and degrees are two ways to measure angles. Radians are a more mathematically convenient way to measure angles, but degrees are more commonly used in everyday life. In JavaScript, we can convert degrees to radians using a simple formula.

The formula to convert degrees to radians is:

``radians = degrees * (Math.PI / 180)``

where degrees is the angle measurement in degrees and Math.PI is the mathematical constant for pi, which is approximately equal to 3.14159.

### Examples

#### Convert 45 degrees to radians

``````const degrees = 45;
const radians = degrees * (Math.PI / 180);
``````

In this example, we first define the angle measurement degrees to be 45. We then use the formula to convert degrees to radians and store the result in the variable radians. The output is the value of radians, which is approximately equal to 0.7854 radians.

#### Convert 90 degrees to radians

``````const degrees = 90;
const radians = degrees * (Math.PI / 180);
``````const degrees = 180;