How to use atan in JavaScript

In this article, I will explain use of atan() method in JavaScript.
  • 1763

JavaScript atan() Method

  • atan() method of math object returns the arctangent in radians of a number.

  • atan() method returns a numeric value between -pi/2 and pi/2 radians.

Syntax

Math.atan(x)

  • x is a Required number

Example

In the following example show to atan() method returns the arctangent of numbers.

<!DOCTYPE html>

<html>

<body>

<h3 style="background-color:Silver">atan() Method Example</h3>

<p id="demo">Click the button to display the arctangent of the number 1</p>

<button onclick="myFunction()">Click</button>

<script type="text/javascript">

    function myFunction() {

        document.getElementById("demo").innerHTML = Math.atan(1);

    }

</script>

</body>

</html>

Output1

atan 1.jpg

Output2

atan 2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.