JavaScript Math.cos()
Definition and Usage
The Math.cos() method returns the cosine of a number.
Note: Math.cos() returns a numeric value between -1 and 1, which represents the cosine of the angle.
Browser Support
Math.cos()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.cos(x)
Parameter Values
Parameter | Description |
---|---|
x | Required. A number |
Return Value
A number from -1 to 1, representing the cosine of an angle. NaN if the value is empty. |