Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript acos() method

JavaScript acos() method

Math Object Reference JavaScript Math object

Example

Return the arccosine of a number:

Math.acos(0.5);

Output result:

Try it »


Definition and Usage

The acos() method returns the arccosine of a number. The returned value is an angle in radians between 0 and PI.

Note: If the parameter x is outside the range -1.0 ~ 1.0, the browser will return NaN.

Tip: If the parameter x is -1, then PI is returned.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the acos() method.


Syntax

Math.acos(

x

)

Parameter value

Parameters Description
x Required. Must be a number between -1.0 and 1.0.

Return Value

Type Description
Number The arccosine of x. The returned value is an angle in radians between 0 and PI.

Technical Details

JavaScript version: 1.0

Math Object Reference JavaScript Math object