Math acos() method is used to return the arccosine of a given number. Number value between the -1 to 1. If you give the other number are string it will return the NaN value.
Syntax:
Math.acos(n)
Example Code:
<script> var positive = Math.acos(-1); document.writeln('acosine of -1 : ' + positive + '</br></br>'); var nullVal = Math.acos(null); document.writeln('arccosine of Null : ' + nullVal + '</br></br>'); var nullVal = Math.acos(1); document.writeln('arccosine of 1 : ' + nullVal + '</br></br>'); var actualVal = Math.acos(10); document.writeln('arccosine of 10 : ' + actualVal + '</br></br>'); var stringVal = Math.acos('Labw3'); document.writeln('arccosine of Labw3 : ' + stringVal + '</br></br>'); </script>
Output:
acosine of -1 : 3.141592653589793 arccosine of Null : 1.5707963267948966 arccosine of 1 : 0 arccosine of 10 : NaN arccosine of Labw3 : NaN