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

How to get the arctangent of the quotient of its arguments in JavaScript?


To get the arctangent of the quotient of its argument, use the atan2() method. It returns a numeric value between -pi and pi representing the angle theta of an (x, y) point.

Example

You can try to run the following code to get the arctangent of the quotient of its argument in JavaScript −

<html>
   <head>
      <title>JavaScript Math atan() Method</title>
   </head>
   <body>
      <script>
         var value = Math.atan(-1);
         document.write("First Value : " + value );

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

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

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

   </body>
</html>