JavaScript 中的 Math.acos() 函数
htmljavascriptweb developmentfront end technology
Math 对象的 acos() 函数接受一个数字并以弧度返回其反余弦值。要将结果值转换为度数,请将其乘以 180,然后将结果除以 3.14159(pi 值)。
语法
其语法如下
Math.acos(0.5)
示例
<html> <head> <title>JavaScript 示例</title> </head> <body> <script type="text/javascript"> var result = Math.acos(0.5); document.write("反余弦值:"+result); document.write("<br>"); document.write("反余弦值(度):"+result*180/Math.PI); </script> </body> </html>
输出
反余弦值:1.0471975511965979 反余弦值(度):60.000000000000001