ฟังก์ชัน tan() ของออบเจ็กต์ Math จะรับมุม (ในหน่วยเรเดียน) และคืนค่า tangent ของมุมนั้น
ไวยากรณ์
รูปแบบการใช้งานคือดังนี้
Math.tan(90)
ตัวอย่าง
<html> <head> <title>ตัวอย่าง JavaScript</title> </head> <body> <script type="text/javascript"> var result = Math.tan(90); document.write("ค่า tangent ของมุมที่ให้มา: "+result); </script> </body> </html>ผลลัพธ์
ค่า tangent ของมุมที่ให้มา: -1.995200412208242