Javascript Math acos()

Introduction

The Math.acos() function returns the arccosine in radians of a number.

Math.acos(x)  

x is a number representing a cosine, where x is between -1 and 1.

The arccosine of the given number if it's between -1 and 1; otherwise, NaN.

let a = Math.acos(-2);  // NaN
console.log(a);//ww w . ja  v a2  s.  c o  m
a = Math.acos(-1);  // 3.141592653589793
console.log(a);
a = Math.acos(0);   // 1.5707963267948966
console.log(a);
a = Math.acos(0.5); // 1.0471975511965979
console.log(a);
a = Math.acos(1);   // 0
console.log(a);
a = Math.acos(2);   // NaN
console.log(a);



PreviousNext

Related