JavaScript cos () method
Examples
Returns the cosine of a number:
Math.cos(3);
Examples of the above output:
-0.9899924966004454
try it"
Definition and Usage
cos () method returns the cosine of a number.
Note: cos () returns a number between -1.0 and 1.0.
Browser Support
All major browsers support cos () method
grammar
Math.cos( x )
Parameter Value
参数 | 描述 |
---|---|
x | 必需。必须是一个数值。 |
return value
Types of | description |
---|---|
Number | Cosine of x. It returns the number of -1.0 to 1.0. |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
Returns the cosine of PI and 2 * PI:
var a = Math.cos (Math.PI);
var b = Math.cos (2 * Math.PI);
var b = Math.cos (2 * Math.PI);
a and b output:
-1
1
1
try it"