AppDividend
Latest Code Tutorials

# JavaScript Math asin Function | Math.asin() In Javascript

Javascript Math asin() is an inbuilt function that is used to find the arcsine value in radians of a given argument. The Math.asin() function returns a numeric value between -pi/2 and pi/2 radians. Javascript asin() is a static method of Math. So, it is always used as Math.asin(), rather than as a method of the Math object.

## JavaScript Math asin

If you want to find the arcsine value of a given argument in JavaScript, then you can use the Math.asin() method. The asin() method comes handy in programming contexts dealing with any trigonometric expressions.

### Syntax

```Math.asin(x)
```

### Parameters

The variable x lying between -1 and 1 whose arcsine value is to be determined.

### Return Value

The arcsine value between -pi/2 and pi/2 radians.

See the following figure.

#### Note:

• If the passed value lies outside the range [-1,1], the method returns NaN.

### Compatibility

• Internet Explorer
• Firefox
• Opera
• Safari
• Android webview
• Chrome for Android
• Firefox for Android
• Opera for Android
• Safari on iOS
• Samsung Internet
• Node.js

JavaScript version: ECMAScript 1

Consider the following examples

### JavaScript Math asin() Code Example

See the following code.

```// example1.js

var a = -1;
var b = 1;
var c = 0.5;
var d = 0;

console.log(Math.asin(a));
console.log(Math.asin(b));
console.log(Math.asin(c));
console.log(Math.asin(d));```

#### Output

```node example1
-1.5707963267948966
1.5707963267948966
0.5235987755982989
0
```

### Example 2

The following example demonstrates the case where values outside the range of [-1,1] are passed as parameters.

```// example2.js

var a = 2;
var b = -2;

console.log(Math.asin(a));
console.log(Math.asin(b));
```

#### Output

```node example2
NaN
NaN
```

### Example 3

The following code example demonstrates the application of this method in a simple programming context.

Given the three sides of a right-angled triangle, find all of its angles.

```// example3.js

var h;
var b;
var p;

const rl = r.createInterface({
input: process.stdin,
output: process.stdout
});

const prompt1 = () => {
return new Promise((resolve, reject) => {
resolve();
});
});
};

const prompt2 = () => {
return new Promise((resolve, reject) => {
resolve();
});
});
};

const prompt3 = () => {
return new Promise((resolve, reject) => {
resolve();
});
});
};

const main = async () => {
await prompt1();
await prompt2();
await prompt3();
rl.close();

console.log('The three angles of the triangle are(in radians):');
console.log(Math.asin(p / h));				//base angle
console.log(Math.asin(1) - Math.asin(p / h)); 		//third angle
}

main();
```

#### Output

```Test Case 1:
->node example3
Hypotenuse: 6.928
Base: 6
Perpendicular: 3.464
The three angles of the triangle are:
1.5707963267948966
0.5235987755982989
1.0471975511965976

Test Case2:
->node example3
Hypotenuse: 42.426
Base: 30
Perpendicular: 30
The three angles of the triangle are(in radians):
1.5707963267948966
0.7854077535813886
0.785388573213508```

Javascript Math asinh()

JavaScript Math atan()

JavaScript Math atanh()

JavaScript Math atan2()

Javascript math cos()

Javascript math.cosh()

Javascript Math.abs()

Javascript Math.round()

Javascript Math.random()

This site uses Akismet to reduce spam. Learn how your comment data is processed.