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