Javascript Math cos()

Introduction

The Math.cos() function returns the cosine of the specified angle in radians.

Math.cos(x) // x is the angle in radians.

The Math.cos() method returns a numeric value between -1 and 1.

let a = Math.cos(0);           // 1
Math.cos(1);           // 0.5403023058681398
console.log(a);/* w w  w . jav a 2  s  . co m*/
a = Math.cos(Math.PI);     // -1
console.log(a);
a = Math.cos(2 * Math.PI); // 1
console.log(a);



PreviousNext

Related