This section illustrates you the use of JavaScript method atan(). The atan() method returns the arc tangent of a specified number as a numeric value between -PI/2 and PI/2 radians. You can see in the given example that we have used the method atan() and want to find out the arc tangent of 2. We have created a button which calls the function calculate() from the script and displays the output.
Here is the code:
| <html> <script> function calculate(){ document.write("The value of atan(2) is: "+Math.atan(2)); } </script> <h2>Use of atan() method</h2> <button onclick="calculate();">Use of method atan</button> </body> </html> |
Output will be displayed as:

On clicking the button, you will get the arc tangent of 2:
![]()
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: JavaScript method atan()
Post your Comment