Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. JavaScript
  3. JavaScript 参考
  4. JavaScript 标准内置对象
  5. Math
  6. Math.sin()

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

Math.sin()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

Math.sin() 静态方法以弧度为单位返回一个数字的正弦值。

尝试一下

function getCircleY(radians, radius) {  return Math.sin(radians) * radius;}console.log(getCircleY(1, 10));// Expected output: 8.414709848078965console.log(getCircleY(2, 10));// Expected output: 9.092974268256818console.log(getCircleY(Math.PI, 10));// Expected output: 1.2246467991473533e-15

语法

js
Math.sin(x)

参数

x

一个数值(以弧度为单位)。

返回值

x 的正弦值,介于 -1 到 1 之间(包含 -1 和 1)。如果xInfinity-InfinityNaN,则返回NaN

描述

由于sin()Math 的静态方法,应该总是以Math.sin() 的形式,而不是作为Math 对象的方法来使用它(Math 不是构造函数)。

示例

使用 Math.sin()

js
Math.sin(-Infinity); // NaNMath.sin(-0); // -0Math.sin(0); // 0Math.sin(1); // 0.8414709848078965Math.sin(Math.PI / 2); // 1Math.sin(Infinity); // NaN

规范

Specification
ECMAScript® 2026 Language Specification
# sec-math.sin

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp