JavaScript Math.asin()
Syntax & Examples


Math.asin() static-method

The Math.asin() method in JavaScript returns the arcsine (inverse sine) of a number. The method returns a value in radians, which is between -π/2 and π/2 (inclusive).


Syntax of Math.asin()

The syntax of Math.asin() static-method is:

Math.asin(x)

This asin() static-method of Math returns the arcsine of x.

Parameters

ParameterOptional/RequiredDescription
xrequiredA number between -1 and 1. If the value of x is outside this range, the method returns NaN.

Return Type

Math.asin() returns value of type Number.



✐ Examples

1 Using Math.asin() with a positive number

In JavaScript, we can use the Math.asin() method to get the arcsine of a positive number.

For example,

  1. We call the Math.asin() method with a positive number x.
  2. The arcsine value is returned and stored in the variable result.
  3. We log result to the console using console.log() method.

JavaScript Program

const x = 0.5;
const result = Math.asin(x);
console.log(result);

Output

0.5235987755982989

2 Using Math.asin() with zero

In JavaScript, we can use the Math.asin() method to get the arcsine of zero.

For example,

  1. We call the Math.asin() method with zero x.
  2. The arcsine value is returned and stored in the variable result.
  3. We log result to the console using console.log() method.

JavaScript Program

const x = 0;
const result = Math.asin(x);
console.log(result);

Output

0

3 Using Math.asin() with a negative number

In JavaScript, we can use the Math.asin() method to get the arcsine of a negative number.

For example,

  1. We call the Math.asin() method with a negative number x.
  2. The arcsine value is returned and stored in the variable result.
  3. We log result to the console using console.log() method.

JavaScript Program

const x = -0.5;
const result = Math.asin(x);
console.log(result);

Output

-0.5235987755982989

Summary

In this JavaScript tutorial, we learned about asin() static-method of Math: the syntax and few working examples with output and detailed explanation for each example.