In JavaScript, we can easily do trigonometry with the many trig functions from the JavaScript math module. In this article, you will learn about all the trigonometric functions that you can use in JavaScript to perform trigonometry easily.

In JavaScript, we can easily use trigonometric functions with the JavaScript math module. The JavaScript math module allows us to perform trigonometry easily.

In this article, we are going to go over all of the trig functions you can use in JavaScript and give examples of how to use each one.

Below is a list of each of the trigonometric functions you can use in JavaScript. If you want, you can keep scrolling or click on one of the links below to go to a section directly.

- pi in JavaScript
- Converting Degrees to Radians in JavaScript
- Converting Radians to Degrees in JavaScript
- JavaScript sin() Function
- JavaScript cos() Function
- JavaScript tan() Function
- JavaScript asin() Function
- JavaScript acos() Function
- JavaScript atan() Function
- JavaScript atan2() Function
- JavaScript sinh() Function
- JavaScript cosh() Function
- JavaScript tanh() Function
- JavaScript asinh() Function
- JavaScript acosh() Function
- JavaScript atanh() Function

## How We Can Use Pi in JavaScript

When doing trigonometry, the most fundamental number is pi.

To get the value of pi in JavaScript, the easiest way is use the JavaScript math module constant pi. Math.PI returns the value 3.141592653589793.

```
import math
console.log(Math.PI)
// Output:
3.141592653589793
```

## How to Convert Degrees to Radians in JavaScript

When working with angles, it’s important to be able to convert between radians and degrees easily.

While JavaScript doesn’t have a function which will convert degrees to radians for us, we can easily define a function. To convert degrees to radians, all we need to do is multiply the degrees by pi divided by 180.

Below are some examples of how we can use the convert degrees to radians in JavaScript.

```
function degrees_to_radians(degrees) {
return degrees * (Math.PI / 180);
}
console.log(degrees_to_radians(0))
console.log(degrees_to_radians(30))
console.log(degrees_to_radians(60))
console.log(degrees_to_radians(90))
// Output:
0.0
0.5235987755982988
1.0471975511965976
1.5707963267948966
```

## How to Convert Radians to Degrees in JavaScript

When working with angles, it’s important to be able to convert between radians and degrees easily.

While JavaScript doesn’t have a function which will convert radians to degrees for us, we can easily define a function. To convert radians to degrees, all we need to do is multiply the degrees by 180 divided by pi.

Below are some examples of how we can use the convert radians to degrees in JavaScript.

```
function radians_to_degrees(radians) {
return radians * (180 / Math.PI);
}
console.log(radians_to_degrees(0))
console.log(radians_to_degrees(Math.PI/6))
console.log(radians_to_degrees(Math.PI/3))
console.log(radians_to_degrees(Math.PI/2))
// Output:
0
29.999999999999996
59.99999999999999
90
```

## How to Find Sine of Number with sin() Function in JavaScript

To find the sine of a number, in radians, we use the JavaScript sin() function.

The input to the **sin()** function must be a numeric value. The return value will be a numeric value between -1 and 1.

Below are a few examples of how to use the JavaScript **sin()** function to find the sine of a number.

```
import math
console.log(Math.sin(Math.PI/3))
console.log(Math.sin(0))
console.log(Math.sin(Math.PI/2))
// Output:
0.8660254037844386
0.0
1.0
```

## How to Find Cosine of Number with cos() Function in JavaScript

To find the cosine of a number, in radians, we use the JavaScript cos() function.

The input to the **cos()** function must be a numeric value. The return value will be a numeric value between -1 and 1.

Below are a few examples of how to use the JavaScript **cos()** function to find the cosine of a number.

```
import math
console.log(Math.cos(Math.PI/3))
console.log(Math.cos(0))
console.log(Math.cos(Math.PI/2))
// Output:
0.5000000000000001
1.0
6.123233995736766e-17
```

## How to Find Tangent of Number with tan() Function in JavaScript

To find the tangent of a number, or the sine divided by the cosine of an angle, in radians, we use the JavaScript tan() function.

The input to the **tan()** function must be a numeric value. The return value will be a numeric value between negative infinity and infinity.

Below are a few examples of how to use the JavaScript **tan()** function to find the tangent of a number.

```
import math
console.log(Math.tan(Math.PI/3))
console.log(Math.tan(0))
console.log(Math.tan(Math.PI/2))
// Output:
1.7320508075688767
0.0
1.633123935319537e+16
```

## How to Find Arcsine of Number with asin() Function in JavaScript

To find the arcsine of a number, we use the JavaScript asin() function.

The input to the **asin()** function must be a numeric value between -1 and 1. The return value will be a numeric value between -pi/2 and pi/2 radians.

Below are a few examples of how to use the JavaScript **asin()** function to find the arcsine of a number.

```
import math
console.log(Math.asin(0.5))
console.log(Math.asin(0))
console.log(Math.asin(-0.75))
// Output:
0.5235987755982989
0.0
-0.848062078981481
```

## How to Find Arccosine of Number with acos() Function in JavaScript

To find the arccosine of a number, we use the JavaScript acos() function.

The input to the **acos()** function must be a numeric value between -1 and 1. The return value will be a numeric value between 0 and pi radians.

Below are a few examples of how to use the JavaScript **acos()** function to find the arccosine of a number.

```
import math
console.log(Math.acos(0.5))
console.log(Math.acos(0))
console.log(Math.acos(-0.75))
// Output:
1.0471975511965979
1.5707963267948966
2.4188584057763776
```

## How to Find Arctangent of Number with atan() Function in JavaScript

To find the arctangent of a number, we use the JavaScript atan() function.

The input to the **atan()** function must be a numeric value. The return value will be a numeric value between -pi/2 and pi/2 radians.

Below are a few examples of how to use the JavaScript **atan()** function to find the arctangent of a number.

```
import math
console.log(Math.atan(5))
console.log(Math.atan(0))
console.log(Math.atan(-3))
// Output:
1.373400766945016
0.0
-1.2490457723982544
```

## How to Find Arctangent of the Quotient of Two Numbers with atan2() Function in JavaScript

JavaScript gives us the ability to find the arctangent of the quotient of two numbers, where the two numbers represents the coordinates of a point (x,y). To find the arctangent of a the quotient of two numbers, we use the JavaScript atan2() function.

The inputs to the **atan2()** function must be a numeric values. The return value will be a numeric value between -pi and pi radians.

Below are a few examples of how to use the JavaScript **atan2()** function to find the arctangent of the quotient of two numbers.

```
import math
console.log(Math.atan2(5,1))
console.log(Math.atan2(0,0))
console.log(Math.atan2(-3,7))
// Output:
1.373400766945016
0.0
-0.40489178628508343
```

## How to Find Hyperbolic Sine of Number with sinh() Function in JavaScript

To find the hyperbolic sine of a number, we can use the JavaScript sinh() function from the math module.

The input to the **sinh()** function must be a numeric value. The return value will be a numeric value.

Below are a few examples of how to use the JavaScript **sinh()** function to find the hyperbolic sine of a number.

```
import math
console.log(Math.sinh(100))
console.log(Math.sinh(0))
console.log(Math.sinh(-50))
// Output:
1.3440585709080678e+43
0.0
-2.592352764293536e+21
```

## How to Find Hyperbolic Cosine of Number with cosh() Function in JavaScript

To find the hyperbolic cosine of a number, we can use the JavaScript cosh() function from the math module.

The input to the **cosh()** function must be a numeric value. The return value will be a numeric value greater than or equal to 1.

Below are a few examples of how to use the JavaScript **cosh()** function to find the hyperbolic cosine of a number.

```
import math
console.log(Math.cosh(100))
console.log(Math.cosh(0))
console.log(Math.cosh(-50))
// Output:
1.3440585709080678e+43
1.0
2.592352764293536e+21
```

## How to Find Hyperbolic Tangent of Number with tanh() Function in JavaScript

To find the hyperbolic tangent of a number, we can use the JavaScript tanh() function from the math module.

The input to the **tanh()** function must be a numeric value. The return value will be a numeric value between -1 and 1.

Below are a few examples of how to use the JavaScript **tanh()** function to find the hyperbolic tangent of a number.

```
import math
console.log(Math.tanh(20))
console.log(Math.tanh(0))
console.log(Math.tanh(-10))
// Output:
1.0
0.0
-0.9999999958776927
```

## How to Find Hyperbolic Arcsine of Number with asinh() Function in JavaScript

To find the hyperbolic arcsine of a number, we can use the JavaScript asinh() function from the math module.

The input to the **asinh()** function must be a numeric value. The return value will be a numeric value.

Below are a few examples of how to use the JavaScript **asinh()** function to find the hyperbolic arcsine of a number.

```
import math
console.log(Math.asinh(10))
console.log(Math.asinh(0))
console.log(Math.asinh(-5.32))
// Output:
2.99822295029797
0.0
-2.3733388650599814
```

## How to Find Hyperbolic Arccosine of Number with acosh() Function in JavaScript

To find the hyperbolic arccosine of a number, we can use the JavaScript acosh() function from the math module.

The input to the **acosh()** function must be a numeric value greater than or equal to 1. The return value will be a numeric value.

Below are a few examples of how to use the JavaScript **acosh()** function to find the hyperbolic arccosine of a number.

```
import math
console.log(Math.acosh(5.23))
console.log(Math.acosh(1.2))
console.log(Math.acosh(100))
// Output:
2.3382907483329896
0.6223625037147786
5.298292365610484
```

## How to Find Hyperbolic Arctangent of Number with atanh() Function in JavaScript

To find the hyperbolic arctangent of a number, we can use the JavaScript atanh() function from the math module.

The input to the **atanh()** function must be a numeric value between -1 and 1. The return value will be a numeric value.

Below are a few examples of how to use the JavaScript **atanh()** function to find the hyperbolic arctangent of a number.

```
import math
console.log(Math.atanh(0.5))
console.log(Math.atanh(0))
console.log(Math.atanh(-0.75))
// Output:
0.5493061443340549
0.0
-0.9729550745276566
```

Hopefully this article has been useful for you to learn how to use the math module trig functions in JavaScript for trigonometry.

## Leave a Reply