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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Math.cos(x)

Parameters

ParameterDescription
x An angle in radians.

Return value

A number between -1 and 1.

Examples

Cosine valuesTry it yourself
console.log(Math.cos(0), Math.cos(Math.PI));

Output

1 -1
Cosine of 60 degreesTry it yourself
const deg = 60;
console.log(Math.cos((deg * Math.PI) / 180).toFixed(2));

Output

0.50

Version history

VersionChange
JavaScript ES1Added

Was this page helpful?