Home »
JavaScript
Math.acos() Method with Example in JavaScript
JavaScript | Math.acos() Method: Here, we are going to learn about the acos() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on February 03, 2020
JavaScript | Math.acos() Method
Math.acos() is a function in math library of JavaScript that is used to find the value of arccosine of a number and return the value in radians.
Syntax:
Math.acos(x);
Parameter(s):
- x – It represents the value whose arccosine value to be found.
Return value:
The return type of this method is number, it returns the arccosine value of the given x.
Values accepted: Integer, floating-point, numeric string.
Invalid Values: non-numeric string, empty variable, empty array all will return NaN (Not a Number).
Example 1: Valid values
console.log(Math.acos(-1));
console.log(Math.acos(0.1));
console.log(Math.acos(0));
console.log(Math.acos("0.65"));
Output
3.141592653589793
1.4706289056333368
1.5707963267948966
0.863211890069541
Example 2: Invalid values
console.log(Math.acos("Javascript"));
console.log(Math.acos(2));
Output
NaN
NaN
JavaScript Math Object Methods »