cos Function

Top  Previous  Next

Returns the cosine of a number.

Syntax

Math.cos(number)

Arguments

numberA number.        

Return Value

A number, within the range -1 and 1, which represents the cosine of the angle. If the is a string, it returns NaN.

Examples

Math.cos(1);      // Returns 0.540302

Math.cos(0.5);    // Returns 0.8775826

Math.cos(0);      // Returns 1

Math.cos(-0.5);   // Returns 0.8775826

Math.cos(-1);     // Returns 0.5403023

See also

Math.sin