Latest web development tutorials

JavaScript acos () method

Math Object Reference JavaScript Math Object

Examples

It returns the inverse cosine of a number:

Math.acos(0.5);

Output:


try it"

Definition and Usage

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

Note: If the parameter x exceeds the range of -1.0 to 1.0, the browser will return NaN.

Tip: If the value of the parameter x -1 is returned PI.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support acos () method


grammar

Math.acos( x )

Parameter Value

参数 描述
x 必需。必须是 -1.0 ~ 1.0 之间的数。

return value

类型 描述
Number x 的反余弦值。返回的值是 0 到 PI 之间的弧度值。

technical details

JavaScript version: 1.0


Math Object Reference JavaScript Math Object