JavaScript Math asin()

The JavaScript Math.asin() function returns the arcsine of a number in radians.

The syntax of the Math.asin() function is:

Math.asin(x)

asin(), being a static method, is called using the Math class name.


Math.asin() Parameters

The Math.asin() function takes in:

  • x - A number whose arcsine is required.

Return value from Math.asin()

  • For values of x between -1 and 1, it returns the arcsine of a number between -π/2 and π/2 radians.
  • For other values, it returns NaN.

Example: Using Math.asin()

// using Math.asin()

// Returns arcsine for -1 <= x <=1
var num = Math.asin(1);
console.log(num); // 1.5707963267948966 (pi/2)

var num = Math.asin(0.5);
console.log(num); // 0.5235987755982989 (pi/6)

var num = Math.asin(-1);
console.log(num); // -1.5707963267948966 (-pi/2)

// Returns NaN for x < -1 or x > 1
var num = Math.asin(100);
console.log(num); // NaN

Output

1.5707963267948966
0.5235987755982989
-1.5707963267948966
NaN

Recommended readings: