Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Javascript

ฟังก์ชัน Math.atan() JavaScript


ฟังก์ชัน atan() ของออบเจกต์ Math ยอมรับตัวเลขและส่งกลับค่าอาร์กแทนเจนต์เป็นเรเดียน หากต้องการแปลงค่าผลลัพธ์เป็นองศา ให้คูณด้วย 180 แล้วหารผลลัพธ์ด้วย 3.14159 (ค่า pi)

ไวยากรณ์

ไวยากรณ์ของมันคือดังต่อไปนี้

Math.atan(0.5)

ตัวอย่าง

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result = Math.atan(0.5);
      document.write("arctangent value: "+result);
      document.write("<br>");
      document.write("arctangent value in degrees: "+result*180/Math.PI);
   </script>
</body>
</html>

ผลลัพธ์

arctangent value: 0.4636476090008061
arctangent value in degrees: 26.56505117707799