English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Math.acos() Method

 JavaScript Math Object

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

If the value of the passed parameter is-1to1outside the range, the method will return NaN.

Because acos() is a static method of Math, you should always use it asMath.acos(), rather than as a method of the Math object created.

Syntax:

Math.acos(x)
Math.acos(0.9);
Test and see‹/›

Browser Compatibility

All browsers fully support the Math.acos() method:

Method
Math.acos()isisisisis

Parameter Value

ParameterDescription
xNumber

Technical Details

Return value:If between-1and1between, the inverse cosine (in radians) of the given number; otherwiseNaN
JavaScript version:ECMAScript 1

More examples

For less than-1or greater1The value, Math.acos() returns NaN:

Math.acos(-2);   // NaN
Math.acos(-1);   // 3.141592653589793
Math.acos(0);// 1.5707963267948966
Math.acos(0.5);  // 1.0471975511965979
Math.acos(1);// 0
Math.acos(2);// NaN
Test and see‹/›

 JavaScript Math Object