Others



JavaScript Math.cos()


The Math.cos(x) method returns the cosine of a number in radians.

Syntax
Math.cos(x)

Here, cos() is a static method. Hence, we use it as Math.cos().

Parameters
  • x - (Required).Angle for which we want to compute the cosine.
Return Value
  • -1 to 1 - The cosine value of the given angle.
  • NaN - non-numeric parameter.
Example
console.log(Math.cos(0));  //1
console.log(Math.cos(-3)); //-0.9899924966004454
console.log(Math.cos(1.5)); //0.0707372016677029
console.log(Math.cos('A')); //NaN
Try it Yourself

JavaScript Math Functions