How to Use the Math.sin() Method in JavaScript | Plantpot

How to Use the Math.sin() Method in JavaScript

Web Dev
Sponsored links

In this article, I will introduce how to use the Math.sin() method in JavaScript.

The Math.sin() method

The Math.sin function returns the sine of the angle specified as an argument.
The angle is specified in radians.

The syntax is below.

Math.sin(x)

x: The angle in radians

If you want to use angles in degrees, you need to convert them to radians.

Math.sin(degrees*(Math.PI/180))

For example, to get sin30°, sin45°, and sin60°:

Math.sin(30*(Math.PI/180));
Math.sin(45*(Math.PI/180));
Math.sin(60*(Math.PI/180));