Others



JavaScript Math.acos()


The Math.acos(x) method returns the arccosine(inverse cosine) of a number in radians.

Syntax
Math.acos(x)

Here, acos() is a static method. Hence, we use it as Math.acos().

Parameters
  • x - (Required).A number for which we want to compute the arccosine.
  • The number must be in the range of -1 to 1.
Return Value
  • The arccosine value of the given angle.
  • NaN - If the parameter is not within the range of -1 and 1, or not numeric.
Example
console.log(Math.acos(-1));  //3.141592653589793
console.log(Math.acos(1));   //0
console.log(Math.acos(0));   //1.5707963267948966
console.log(Math.acos(5));   //NaN
console.log(Math.acos('A')); //NaN
Try it Yourself

JavaScript Math Functions