JavaScript Math.sin() Method

Definition
Math.sin(x) returns the sine of an angle. The angle must be in radians, not degrees. The result is always between -1 and 1.
Read the syntax below, then try the three examples to see the method in action.
Syntax
Call the method on Math. Start with this line.
| Call | What it does |
|---|
Math.sin(x) | Returns the sine of x, where x is in radians. |
Built into JavaScript. Call Math.sin(...) on the Math object — no import required. Math is not a constructor, so never write new Math().
Library declarations
Parameters
| Parameter | Description |
|---|
| x | Required. The angle in radians. |
Return Value
| Return Value | Description |
|---|
| Number | A number from -1 to 1. Returns NaN if x is Infinity or not a number. |
JavaScript Examples
Example 1 — Basic Sine Values
Use Math.PI to write common angles in radians.
console.log(Math.sin(0)); // 0
console.log(Math.sin(Math.PI / 2)); // 1
console.log(Math.sin(Math.PI / 6)); // 0.49999999999999994
How It Works
- Zero. The sine of
0 is 0. - Quarter turn.
Math.PI / 2 is 90 degrees, and its sine is 1. - 30 degrees.
Math.PI / 6 is 30 degrees. The sine should be 0.5. - Tiny error. The computer shows
0.49999999999999994, a very small rounding difference. Use toFixed() to show a clean number.
Example 2 — Use Degrees with a Helper
Write a small function that converts degrees to radians before calling Math.sin().
function sinDeg(deg) {
return Math.sin(deg * Math.PI / 180);
}
console.log(sinDeg(30).toFixed(2)); // 0.50
console.log(sinDeg(90).toFixed(2)); // 1.00
console.log(sinDeg(180).toFixed(2)); // 0.00
How It Works
- Convert.
deg * Math.PI / 180 changes degrees into radians. - 30 degrees. The sine is
0.50. - 90 degrees. The sine is
1.00. - 180 degrees. The true value is
0. The raw result is a tiny number, so toFixed(2) shows 0.00.
Example 3 — Points on a Sine Wave
Step through a quarter turn at a time and watch the value rise and fall.
for (let step = 0; step <= 3; step++) {
const angle = step * Math.PI / 2;
console.log(angle.toFixed(2) + " -> " + Math.sin(angle).toFixed(2));
}
0.00 -> 0.00
1.57 -> 1.00
3.14 -> 0.00
4.71 -> -1.00
How It Works
- Quarter turns.
step * Math.PI / 2 gives 0, 90, 180 and 270 degrees in radians. - Up. The value goes from
0.00 to 1.00. - Back to zero. At 180 degrees it returns to
0.00. - Down. At 270 degrees it reaches
-1.00. This up and down shape is the sine wave.
Compatibility
Browser & Runtime Support
Math.sin is part of the first JavaScript standard (ES1) and is Baseline Widely available in every browser and in Node.js.
✓ Baseline · ES1
Math.sin
Supported in Chrome, Firefox, Safari, Edge, Internet Explorer and Node.js for many years. No polyfill needed.
99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full supportMath.sin Excellent
Bottom line: Use Math.sin anywhere. It works in all browsers.
Frequently Asked Questions
Math.sin(x) returns the sine of an angle x. The angle must be in radians. The answer is always between -1 and 1.
Radians. To use degrees, convert with degrees * Math.PI / 180.
Math.PI is a rounded number, so the result is a tiny value like 1.2246467991473532e-16. Round it with toFixed() if you want a clean answer.
It returns NaN. The sine of Infinity is not defined.
Math.asin() is the inverse. It takes a number from -1 to 1 and returns the angle in radians.
All of them. It is part of the first JavaScript standard and works in every browser and in Node.js.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful