Skip to content
Related Articles

Related Articles

JavaScript Math cos( ) Method

Improve Article
Save Article
  • Last Updated : 18 Oct, 2022
Improve Article
Save Article

The Math.cos() method is used to return the cosine of a number. The Math.cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle given in radians. The cos() is a static method of Math, therefore, it is always used as Math.cos(), rather than as a method of a Math object created.

Syntax: 

Math.cos(value)

Parameters: This function accepts single parameter as mentioned above and described below: 

  • Value: This parameter is a number given in radians.

Returns: The Math.cos() function returns the cosine of the given numbers which range from -1 to 1.

Below is an example of the Math cos() Method. 

Example: 

Javascript




<script type="text/javascript">
    console.log("The cos of 0 : " + Math.cos(0));
</script>

Output: 

The cos of 0 : 1

Example 1: 

Input: Math.cos(010)
Output : -0.14550003380861354

Example 2: 

Input: Math.cos(10)
Output : -0.8390715290764524

More codes for the above method are as follows: 

Program 1: When 1 is passed as a parameter.

Javascript




<script type="text/javascript">
    console.log("Result : " + Math.cos(1));
</script>

Output: 

Result : 0.5403023058681398

Program 2: When PI is passed as a parameter.  

Javascript




<script type="text/javascript">
    console.log("Result : " + Math.cos(Math.PI));
</script>

Output: 

Result : -

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!