代码示例:(标识:eg_js_math_cos)
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Math.cos()</h1>

<p>Math.cos(x) 返回 x(以弧度计)的余弦:</p>

<p>以弧度计的角度 = (以度数计的角度) * PI / 180。</p>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 
"The cosine value of 0 degrees is " + Math.cos(0 * Math.PI / 180);
</script>

</body>
</html>
运行结果: