# Using Math cos() function to coding in Javascript/JS

This JavaScript tutorial explains how to use the math function referred to as cos() with syntax and examples.

## Description

In JavaScript, cos() is a characteristic that is used to return the cosine of a number. Because the cos() function is a static function of the Math object, it need to be invoked thru the placeholder object referred to as Math.

## Syntax

In JavaScript, the syntax for the cos() characteristic is:

``Math.cos(number);``

Parameters or Arguments

number The variety used to calculate the cosine. It is the price of an attitude expressed in radians.

## Returns

The cos() function returns the cosine of a number. The result will be a price between 1 and -1.

## Note

To convert levels to radians, multiply via 2π/360 or 0.017453293. Math is a placeholder object that carries mathematical functions and constants of which cos() is one of these functions.

## Example

Let’s take a look at an instance of how to use the cos() function in JavaScript.

For example:

``````console.log(Math.cos(0.75));
console.log(Math.cos(-0.9));
console.log(Math.cos(2));``````

In this example, we have invoked the cos() function using the Math class.

We have written the output of the cos() function to the web browser console log, for demonstration purposes, to exhibit what the cos() function returns.

The following will be output to the net browser console log:

``````0.7316888688738209
0.6216099682706644
-0.4161468365471424``````

In this example, the first output to the console log again 0.7316888688738209 which is the cosine of 0.75.

The second output to the console log lower back 0.6216099682706644 which is the cosine of -0.9.

The 0.33 output to the console log again -0.4161468365471424 which is the cosine of two