Math.sin()
Returns the sine of an angle given in radians.
Syntax
Math.sin(x) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
x | number | Yes | The angle in radians. |
Returns
number — The sine of x, between -1 and 1.
Examples
console.log(Math.sin(0));
Output
0
console.log(Math.sin(Math.PI / 2));
Output
1
Notes
The argument is in radians, not degrees - convert with
`degrees * Math.PI / 180`. Floating-point error means `Math.sin(Math.PI)` is a
tiny number, not exactly 0.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |