Home >>JavaScript Math Reference >JavaScript acos() Method
JavaScript acos() method is used to return the arccosine value of a given input number. It returns the value between 0 and PI radians. If the parameter x is outside the range -1 to 1 then the method will return NaN and if it is equal to -1 then it will return the value of PI.
Syntax:
Math.acos(x)
Parameter | Description |
---|---|
x | This is a required parameter. It defines the given input number. |
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
acos() | Yes | Yes | Yes | Yes | Yes |
Here is an example of JavaScript acos() method:
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = Math.acos(0.77); } </script> </body> </html>
Click the button to see the Output.
Example 2:
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction1()">Try it</button> <p id="demo1"></p> <script> function myFunction1() { document.getElementById("demo1").innerHTML = Math.acos(-1); } </script> </body> </html>
Click the button to see the Output.