Computer >> Computer tutorials >  >> Programming >> Javascript

How to get the arcsine (in radians) of a number in JavaScript?


To get the arcsine of a number in radians, use the asin() method. This method returns the arcsine in radians of a number. The asin method returns a numeric value between -pi/2 and pi/2 radians for x between -1 and 1. If the value of a number is outside this range, it returns NaN.

Example

You can try to run the following code to get the arcsine of a number −

<html>
   <head>
      <title>JavaScript Math asin() Method</title>
   </head>

   <body>

      <script>
         var value = Math.asin(-1);
         document.write("First Value: " + value );

         value = Math.asin(null);
         document.write("<br />Second Value: " + value );

         value = Math.asin(30);
         document.write("<br />Third Value: " + value );

         value = Math.asin("Demo Text");
         document.write("<br />Fourth Value: " + value );
      </script>

   </body>
</html>