JavaScript Math.sin() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
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.

JavaScript
Math.sin(x)
CallWhat 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
JavaScript
Math.sin(x)

Parameters

ParameterDescription
xRequired. The angle in radians.

Return Value

Return ValueDescription
NumberA 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.

JavaScript
console.log(Math.sin(0)); // 0
console.log(Math.sin(Math.PI / 2)); // 1
console.log(Math.sin(Math.PI / 6)); // 0.49999999999999994
Try It Yourself

How It Works

  1. Zero. The sine of 0 is 0.
  2. Quarter turn. Math.PI / 2 is 90 degrees, and its sine is 1.
  3. 30 degrees. Math.PI / 6 is 30 degrees. The sine should be 0.5.
  4. 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().

JavaScript
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
Try It Yourself

How It Works

  1. Convert. deg * Math.PI / 180 changes degrees into radians.
  2. 30 degrees. The sine is 0.50.
  3. 90 degrees. The sine is 1.00.
  4. 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.

JavaScript
for (let step = 0; step <= 3; step++) {
  const angle = step * Math.PI / 2;
  console.log(angle.toFixed(2) + " -> " + Math.sin(angle).toFixed(2));
}
Try It Yourself

How It Works

  1. Quarter turns. step * Math.PI / 2 gives 0, 90, 180 and 270 degrees in radians.
  2. Up. The value goes from 0.00 to 1.00.
  3. Back to zero. At 180 degrees it returns to 0.00.
  4. Down. At 270 degrees it reaches -1.00. This up and down shape is the sine wave.

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 support
Math.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.

Next: sinh()

Learn how to hyperbolic sine.

sinh() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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