Last Updated : 15 Jul, 2024
The Javascript Math.cos() method is used to return the cosine of a number. The Math.cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle given in radians. The cos() is a static method of Math, therefore, it is always used as Math.cos(), rather than as a method of a Math object created.
Syntax:Math.cos(value)Parameters:
This function accepts a single parameter as mentioned above and described below:
Example: This example returns the cosine of 0.
JavaScript
console.log("The cos of 0 : " + Math.cos(0));
Example 2: This example returns the cosine of 010.
JavaScript
console.log("Result : " + Math.cos(010));
Result : -0.14550003380861354
Example 3: When 1 is passed as a parameter.
JavaScript
console.log("Result : " + Math.cos(1));
Result : 0.5403023058681398
Example 4: When PI is passed as a parameter.
JavaScript
console.log("Result : " + Math.cos(Math.PI));
Example 5: When Input is in degrees (not in radians)
JavaScript
const degree = 90;
console.log(
"cos(" + degree + ") = " + Math.cos((Math.PI * degree) / 180));
cos(90) = 6.123233995736766e-17Supported Browsers:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4