Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript
math
acos
communitycreator

# What is Math.acos() in JavaScript? Arslan Bajwa

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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.

## Syntax

Math.acos(param);

## Parameter

• 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:
• -1 <= param <= 1

Number in JavaScript is a 64-bit double-precision value which is the same as double in C# or Java.

## Return value

• Number: This returns the angle θ whose cosine is equal to the given param. It is of the Number type. Its range is:

• 0 <= θ <= π (radians)
• NaN: The function returns NaN if:

• param < -1
• param > 1

Radians can be converted to degrees with the formula:

• Degrees = Radians × 180 / π

where π = 3.14159, approximately.

## Example

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));

RELATED TAGS

javascript
math
acos
communitycreator

CONTRIBUTOR Arslan Bajwa

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Learn in-demand tech skills in half the time 