30秒学会 JavaScript 片段 · 2019年8月21日

30秒学会 JavaScript 片段 – radsToDegrees

Converts an angle from radians to degrees.

Use Math.PI and the radian to degree formula to convert the angle from radians to degrees.

代码片段

const radsToDegrees = rad => (rad * 180.0) / Math.PI;

使用样例

radsToDegrees(Math.PI / 2); // 90