JavaScript - Math.acos() Method
The JavaScript Math.acos() method returns arc cosine of a value. The returned value will be in the range 0 through 𝜋.
Syntax
Math.acos(x)
Parameters
x |
Specify the value in range [-1, 1]. |
Return Value
Returns the arc cosine of the value.
If the x is not in the range of [-1, 1], it returns NaN.
Example:
In the example below, Math.acos() method is used to find out the arc cosine of a given value.
var txt; txt = "Math.acos(0.25) = " + Math.acos(0.25) + "<br>"; txt = txt + "Math.acos(0.5) = " + Math.acos(0.5) + "<br>"; txt = txt + "Math.acos(1) = " + Math.acos(1) + "<br>";
The output (value of txt) after running above script will be:
Math.acos(0.25) = 1.318116071652818 Math.acos(0.5) = 1.0471975511965979 Math.acos(1) = 0
❮ JavaScript - Math Object