acos

Returns the arccosine (in radians) of a number.

Applies to

Math

Syntax

acos(x)

Parameters

x

A number.

Description

The acos method returns a numeric value between 0 and pi radians. If the value of number is outside this range, it returns 0.

acos is a static method of Math. As a result, you always use it as Math.acos(), rather than as a method of a Math object you create.

Example

The following function returns the arccosine of the variable x:

function getAcos(x) {
      return Math.acos(x)
}

If you pass -1 to getAcos, it returns 3.141592653589793; if you pass 2, it returns 0 because 2 is out of range.

See also

Math:asin, Math:atan, Math:atan2, Math:cos, Math:sin, Math:tan