JavaScript - Math.sin() Method
The JavaScript Math.sin() method returns trigonometric sine of an angle (angle should be in radians). In the graph below, sin(x) vs x is plotted.
Syntax
Math.sin(x)
Parameters
x |
Specify the angle in radian. |
Return Value
Returns the trigonometric sine of an angle.
Example:
In the example below, Math.sin() method is used to find out the trigonometric sine of an angle.
//Math.PI - value of PI from Math object var pi = Math.PI; var txt; txt = "Math.sin(pi/6) = " + Math.sin(pi/6) + "<br>"; txt = txt + "Math.sin(pi/4) = " + Math.sin(pi/4) + "<br>"; txt = txt + "Math.sin(pi/3) = " + Math.sin(pi/3) + "<br>";
The output (value of txt) after running above script will be:
Math.sin(pi/6) = 0.49999999999999994 Math.sin(pi/4) = 0.7071067811865475 Math.sin(pi/3) = 0.8660254037844386
❮ JavaScript - Math Object