JavaScript (ES2026) reference · Math Methods and Constants
JavaScript Math.sin() Method
Return the sine of an angle given in radians. Convert degrees with deg * Math.PI / 180 first.
JavaScript (ES2026) Since ES1
Syntax
Math.sin(x)
Parameters
| Parameter | Description |
|---|---|
x |
An angle in radians. |
Return value
A number between -1 and 1.
Examples
const rad = (deg) => (deg * Math.PI) / 180;
console.log(Math.sin(rad(30)).toFixed(4), Math.sin(rad(90)));
Output
0.5000 1
const points = [0, 1, 2, 3].map((i) => {
const a = (i * Math.PI) / 2;
return [Math.round(Math.cos(a)) || 0, Math.round(Math.sin(a)) || 0]; // || 0 turns -0 into 0
});
console.log(points);
Output
[ [ 1, 0 ], [ 0, 1 ], [ -1, 0 ], [ 0, -1 ] ]
Version history
| Version | Change |
|---|---|
| JavaScript ES1 | Added |
Related
Math.cos()· Return the cosine of an angle given in radians. Convert degrees with deg * Math.PI / 180 first.Math.atan2()· Return the angle in radians between the positive x axis and the point (x, y). Note the argument order: y first.Math.PI· The ratio of a circle's circumference to its diameter, approximately 3.14159.- JavaScript Math · tutorial
- JavaScript Numbers · tutorial