Javascript Reference - JavaScript asin() Method








The asin() method returns the arcsine between -PI/2 and PI/2 radians.

If the parameter x is outside the range -1 to 1, it returns NaN.

Browser Support

asin() Yes Yes Yes Yes Yes

Syntax

Math.asin(x);

Parameter Values

Parameter Description
x Required. A number




Return Value

The asin() method returns the arcsine of a number as a value between -PI/2 and PI/2 radians.

If the parameter x is outside the range -1 to 1, it returns NaN.

Example

The following code shows how to calculates and returns the arcsine of a number.

<!DOCTYPE html>
<html>
<body>
  <script language="JavaScript">
    function doMath() {<!--  w  w w .j a v a 2s. c  o  m-->
      var inputNum = document.form1.input.value;
      var result = Math.asin(inputNum);
      document.form1.answer.value = result;
    }
  </script>
  <form name=form1>
    This example calculates the arcsine of the entered number. <br>
    <br> Enter Number: <input type="text" name="input" size=10>
    <input type="button" value="Calculate" onClick='doMath()'> <br>
    The arcsin is: <input type="text" name="answer" size=10>
  </form>
</body>
</html>

Click to view the demo