JavaScript Math asin()

In this tutorial, you will learn about the JavaScript Math.asin() method with the help of examples.

The asin() method calculates the arcsine (inverse of sine) of the specified angle and returns it.


let value = Math.asin(1);

// Output: 1.5707963267948966

asin() Syntax

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


Here, asin() is a static method. Hence, we are accessing the method using the class name, Math.

asin() Parameter

The asin() method takes a single parameter:

  • angle - in radians whose arcsine is to be calculated

Note: The value of angle should be between -1 and 1.

asin() Return Value

The asin() method returns:

  • arcsine value of the angle
  • NaN (Not a Number) if the argument is either non-numeric or greater than 1 or less than -1

Example 1: Math.asin() with argument between -1 and 1

// arcsine of negative number let number1 = Math.asin(-1);
// arcsine of positive number let number2 = Math.asin(0.5);
console.log(number2); // Output: // -1.5707963267948966 // 0.5235987755982989

In the above example, the Math.asin() method computes the arcsine of

  • -1 (negative number) - results in -1.5707963267948966
  • 0.5 (positive number) - results in 0.5235987755982989

Example 2 : Math.asin() for other Argument not in the range -1 and 1

// argument less than -1 let number1 = Math.asin(-100);
console.log(number1); // Output: NaN
// argument greater than 1 let number2= Math.asin(32)
; console.log(number2); // Output: NaN

Here, we get NaN as output because both the arguments, -100 and 32, are not in the range -1 and 1.

Example 3: Math.asin() with Non-Numeric Argument

let string = "Harry";
// asin() with a string argument let value = Math.asin(string);
console.log(value); // Output: // NaN

In the above example, we have tried to calculate the arcsine of the string "Harry". That's why we get NaN as the output.

Recommended readings:

Did you find this article helpful?