JavaScript (ES2026) reference · Math Methods and Constants
JavaScript Math.cos() Method
Return the cosine of an angle given in radians. Convert degrees with deg * Math.PI / 180 first.
JavaScript (ES2026) Since ES1
Syntax
Math.cos(x)
Parameters
| Parameter | Description |
|---|---|
x |
An angle in radians. |
Return value
A number between -1 and 1.
Examples
console.log(Math.cos(0), Math.cos(Math.PI));
Output
1 -1
const deg = 60;
console.log(Math.cos((deg * Math.PI) / 180).toFixed(2));
Output
0.50
Version history
| Version | Change |
|---|---|
| JavaScript ES1 | Added |
Related
Math.sin()· Return the sine of an angle given in radians. Convert degrees with deg * Math.PI / 180 first.Math.atan2()· Return the angle in radians between the positive x axis and the point (x, y). Note the argument order: y first.- JavaScript Math · tutorial
- JavaScript Numbers · tutorial