Start of main content
Convert between degrees and radians in JavaScript
JavaScript, Math · Sep 15, 2023

Degrees to radians
JavaScript's Math.PI
constant can be used to convert an angle from degrees to radians. The conversion formula is radians = degrees * Math.PI / 180.0
.
const degreesToRads = deg => (deg * Math.PI) / 180.0;
degreesToRads(90.0);
Radians to degrees
Conversely, the conversion formula from radians to degrees is degrees = radians * 180.0 / Math.PI
.
const radsToDegrees = rad => (rad * 180.0) / Math.PI;
radsToDegrees(Math.PI / 2);
More like this

Learn how to convert between different units of measurement in JavaScript.
Collection · 4 snippets

Learn how to create a unit converter data structure in JavaScript that can convert between any compatible units.
JavaScript, Math · Nov 8, 2023

Find the n
minimum or maximum elements in a JavaScript array quickly and easily.
JavaScript, Math · Oct 5, 2023

Converts an integer to its roman numeral representation.
Accepts value between 1
and 3999
(both inclusive).
JavaScript, Math · Oct 22, 2020