Math.cos

Returns the cosine of a number.

Method of Math
Static

Syntax

cos( x )

Parameters

Parameter Description
x A number

Description

The cos method returns a numeric value between -1 and 1, which represents the cosine of the angle.
Because cos is a static method of Math, you always use it as Math.cos(), rather than as a method of a Math object you created.

Examples

The following function returns the cosine of the variable x:

If x equals 2*Math.PI, getCos returns 1; if x equals Math.PI, the getCos method returns -1.

See also

Math.acos, Math.asin, Math.atan, Math.atan2, Math.sin, Math.tan

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.