Math.cos(x) 返回角度 x(以弧度计)的余弦

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h1>JavaScript Math.cos()</h1>
  6.  
  7. <p>Math.cos(x) 返回 x(以弧度计)的余弦:</p>
  8.  
  9. <p>以弧度计的角度 = (以度数计的角度) * PI / 180。</p>
  10.  
  11. <p id="demo"></p>
  12.  
  13. <script>
  14. document.getElementById("demo").innerHTML =
  15. "The cosine value of 0 degrees is " + Math.cos(0 * Math.PI / 180);
  16. </script>
  17.  
  18. </body>
  19. </html>