JavaScript cos() Method

Clash Royale CLAN TAG#URR8PPP
<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]-->
JavaScript cos() Method
❮ JavaScript Math Object
Example
Return the cosine of a number:
Math.cos(3);
<!--
The output of the code above will be:
-0.9899924966004454
-->Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The cos() method returns the cosine of a number.
Note: The cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle.
Browser Support
| Method | |||||
|---|---|---|---|---|---|
| cos() | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.cos(x)Parameter Values
| Parameter | Description |
|---|---|
| x | Required. A number |
<!--
mid_content, all: [300,250][336,280][728,90][970,250][970,90][320,50][468,60]-->
Technical Details
| Return Value: | A Number, from -1 to 1, representing the cosine of an angle, or NaN if the value is empty |
|---|---|
| JavaScript Version: | ECMAScript 1 |
More Examples
Example
Return the cosine PI and 2*PI:
var a = Math.cos(Math.PI);
var b = Math.cos(2 * Math.PI);
<!--
The result of a and b will be:
-1
1
-->Try it Yourself »
❮ JavaScript Math Object