Definition and Usage The acos() method returns the arccosine of a number as a numeric value value between 0 and PI radians. Syntax M...
Definition and Usage
The acos() method returns the arccosine of a number as a numeric value value between 0 and PI radians.
Syntax
Parameter | Description |
x | Required. Must be a numeric value in the range -1 to 1 |
Tips and Notes
Note: If the parameter x is outside the range -1 to 1, the browser will return NaN.
Note: -1 will return the value of PI.
Example
In this example we will get the arccosine of different numbers:
<script type="text/javascript"> document.write(Math.acos(0.64) + "<br />");
document.write(Math.acos(0) + "<br />");
document.write(Math.acos(-1) + "<br />");
document.write(Math.acos(1) + "<br />");
document.write(Math.acos(2)); </script> |
The output of the code above will be:
0.8762980611683406
1.5707963267948965
3.141592653589793
0
NaN |