90
JavaScript Math acos() method
The JavaScript math acos() method returns the arccosine of the given number in the form of radians. The acos() method must be in the range -1 to 1, otherwise it returns NaN.
Syntax
The acos() method is represented by the following syntax:
Parameter
num – A number.
Return
The arccosine of the number.
JavaScript Math acos() method example
Here, we will understand acos() method through various examples.
Example 1
Let’s see a simple example of acos() method.
Output:
3.141592653589793 1.5707963267948966 1.0471975511965979 0
Example 2
Let’s see some cases where acos() method returns NaN.
Output:
NaN NaN NaN
Example 3
Here, you can test acos() method with your own test cases.
Next TopicJavaScript Math