Easy Tutorial
❮ Prop Cssstyle Parentrule Jsref Prototype Array ❯

JavaScript cos() Method

JavaScript Math Object

Example

Returns the cosine of a number:

The output of the above example:


Definition and Usage

The cos() method returns the cosine of a number.

Note: The cos() method returns a value between -1.0 and 1.0.


Browser Support

All major browsers support the cos() method.


Syntax

Parameter Values

Parameter Description
x Required. Must be a numeric value.

Return Value

Type Description
Number The cosine of x. The return value is between -1.0 and 1.0.

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

Returns the cosine of PI and 2*PI:

var a = Math.cos(Math.PI);
var b = Math.cos(2 * Math.PI);

The output for a and b:

-1
1

JavaScript Math Object

❮ Prop Cssstyle Parentrule Jsref Prototype Array ❯