Math.cos

cos — Returns the cosine of an angle measured in radians.

Description

Math.cos(number radians)

Parameters

Name Description Type Default Optional
radians number No

Return values

number. A number between -1 and 1 representing cosine of the angle.

Examples

Example #1 – cos example
console.log(Math.cos(0)); // 1 console.log(Math.cos(1)); // 0.5403023058681398 console.log(Math.cos(9)); // -0.911130261884677 console.log(Math.cos(Math.PI)); // -1 console.log(Math.cos(2 * Math.PI)); // 1 console.log(Math.cos(-1)); // 0.5403023058681398

External references