Math.cos() return the cosine of a number. The cos method returns the number value between -1 and 1 its represent the cosine of the angle.
Syntax:
Math.cos(x)
Example:
<script> var one = Math.cos(45); document.writeln('Output of 45 is : ' + one + '</br></br>'); var two = Math.cos(90); document.writeln('Output of 90 is : ' + two + '</br></br>'); var three = Math.cos(-1); document.writeln('Output of -1 is : ' + three + '</br></br>'); var four = Math.cos(2 * Math.PI); document.writeln('Output of 2 * Math.PI is : ' + four + '</br></br>'); </script>
Output:
Output of 45 is : 0.5253219888177297 Output of 90 is : -0.4480736161291702 Output of -1 is : 0.5403023058681398 Output of 2 * Math.PI is : 1