The cos() method returns the cosine of a number.
The cos() method returns the cosine of a number.
The cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle.
Math.cos(x)
Parameter | Require | Description |
---|---|---|
x | Required. | A number |
A Number, from -1 to 1, representing the cosine of an angle, or NaN if the value is empty
Return the cosine of a number:
//display the cosine value of 3. console.log(Math.cos(3));//from w w w .ja v a 2 s. c om //Return the cosine PI and 2*PI: var a = Math.cos(Math.PI); var b = Math.cos(2 * Math.PI); console.log(a + "\n" + b);