JavaScript Math.cos() 函数

Math.cos(x) -- 返回数字的余弦值
  • cos是cosine的缩写,中文"余弦"的意思
  • 引用网址:http://www.dreamdu.com/javascript/Math.cos/

cos函数语法

Math.cos(x);

cos函数参数

  • x -- 为number类型的弧度,角度乘以0.017(2π/360)可以转变为弧度

cos函数返回值

返回x的余弦值,此值在-1.0与1.0之间

cos函数示例

document.write(Math.cos(0));
document.write(Math.cos(Math.PI));
document.write(Math.cos(2*Math.PI));
document.write(Math.cos(5));
document.write(Math.cos(-5));

结果:

1
-1
1
0.28366218546322625
0.28366218546322625

JavaScript Math.cos() 函数示例 -- 可以尝试编辑



  • 教程中有什么不懂的地方?发现教程的错误!对教程有什么建议!快快给我留言呀 给猴子留言,我会尽快解答你的问题:)
  • HTML代码