In JavaScript, Math
is a built-in object that contains different methods and properties to perform mathematical operations. It contains a function acos()
, which is used to compute the arc cosine of a specified number. This is also known as the inverse cosine of a number.
Math.acos(param);
param
: This is a number that represents the cosine value. It is the input value of type Number
for which we want to find the acos()
. Its range is:
Number
in JavaScript is a 64-bit double-precision value which is the same asdouble
in C# or Java.
Number
: This returns the angle θ whose cosine is equal to the given param
. It is of the Number
type. Its range is:
NaN
: The function returns NaN
if:
param
< -1param
> 1Radians can be converted to degrees with the formula:
- Degrees = Radians × 180 / π
where
π
= 3.14159, approximately.
console.log("acos(-1) = " + Math.acos(-1));console.log("acos(0) = " + Math.acos(0));console.log("acos(1) = " + Math.acos(1));console.log("acos(0.5) = " + Math.acos(0.5));console.log("acos(-2) = " + Math.acos(-2));console.log("acos(2) = " + Math.acos(2));