Computer >> Computer tutorials >  >> Programming >> Javascript

Math.acos() function in JavaScript


The acos() function of the Math object accepts a number and returns its arc cosine value in radians. To convert the resultant value into degrees, multiply it with 180 and divide the result by 3.14159 (pi value).

Syntax

Its Syntax is as follows

Math.acos(0.5)

Example

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result = Math.acos(0.5);
      document.write("arccosine value: "+result);
      document.write("<br>");
      document.write("arccosine value in degrees: "+result*180/Math.PI);
   </script>
</body>
</html>

Output

arccosine value: 1.0471975511965979
arccosine value in degrees: 60.00000000000001