• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / JavaScript / How to Convert Radians to Degrees Using JavaScript

How to Convert Radians to Degrees Using JavaScript

February 4, 2022 Leave a Comment

To convert radians to degrees using JavaScript, you need to multiply the radians by 180 and divide by pi. Below is a function which will convert radians to degrees for you in JavaScript.

function radians_to_degrees(radians) {
  return radians * (180 / Math.PI);
}

Converting radians to degrees involves the application of a very easy formula.

While JavaScript doesn’t have a function which will convert radians to degrees for us, we can easily define a function. To convert radians to degrees, all we need to do is multiply the degrees by 180 divided by pi.

We can convert radians to degrees without the help of the math module easily in Python.

Below is a user-defined function which will convert radians to degrees for us in our Python code.

function radians_to_degrees(radians) {
  return radians * (180 / Math.PI);
}

Below are some examples of how to convert a number in radians to degrees using JavaScript.

function radians_to_degrees(radians) {
  return radians * (180 / Math.PI);
}

console.log(radians_to_degrees(0))
console.log(radians_to_degrees(Math.PI/6))
console.log(radians_to_degrees(Math.PI/3))
console.log(radians_to_degrees(Math.PI/2))

// Output:
0
29.999999999999996
59.99999999999999
90

Converting Degrees to Radians in JavaScript

If you want to go the other way, from degrees to radians, you have to define another function in JavaScript.

Luckily, the formula is just a reverse of the radians to degrees conversion formula. To convert degrees to radians, we multiply by pi and divide by 180.

Below are some examples of how to convert a number in degrees to radians using JavaScript.

function degrees_to_radians(degrees) {
  return degrees * (Math.PI / 180);
}

console.log(degrees_to_radians(0))
console.log(degrees_to_radians(30))
console.log(degrees_to_radians(60))
console.log(degrees_to_radians(90))

// Output:
0.0
0.5235987755982988
1.0471975511965976
1.5707963267948966

Hopefully this article has been useful for you to learn how to convert radians to degrees in your JavaScript code.

Other Articles You'll Also Like:

  • 1.  Using JavaScript to Resize an Image
  • 2.  JavaScript Check If Number is a Whole Number
  • 3.  Remove Commas From a String in JavaScript
  • 4.  Using JavaScript to Get the Domain From URL
  • 5.  Using JavaScript to Show and Hide a Div
  • 6.  JavaScript indexOf – Get the position of a value within a string
  • 7.  Get the First Child Element and Change it with JavaScript
  • 8.  Using JavaScript to Round to 1 Decimal
  • 9.  Creating a JavaScript Function to Add Two Numbers
  • 10.  JavaScript tan – Find Tangent of Number in Radians Using Math.tan()

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy