运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Math</h1> <h2>The Math.cos() Method</h2> <p>Math.cos() returns the cosine of an angel given in radians.</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "Cosine of 0 degrees is: " + Math.cos(0).toFixed(2) + "<br>" + "Cosine of 60 degrees is: " + Math.cos(Math.PI/3).toFixed(2) + "<br>" + "Cosine of 90 degrees is: " + Math.cos(Math.PI/2).toFixed(2) + "<br>" + "Cosine of 180 degrees is: " + Math.cos(Math.PI).toFixed(2) + "<br>" + "Cosine of 360 degrees is: " + Math.cos(Math.PI*2).toFixed(2); </script> </body> </html>