เมธอด console.log() ใน JavaScript ใช้สำหรับเขียนข้อความในคอนโซล (console)
โค้ดตัวอย่างสำหรับเมธอด console.log() ใน JavaScript ดังนี้ -
ตัวอย่าง
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } </style> </head> <body> <h1>console.log() Example</h1> <button class="Btn">CLICK HERE</button> <h3>คลิกปุ่มข้างบนเพื่อดูผลลัพธ์ในคอนโซลของคุณ</h3> <script> let test = { a:22, b:'HELLO', c:44, } console.log(test); console.log('HELLO WORLD'); </script> </body> </html>
ผลลัพธ์

เมื่อคลิกปุ่ม "CLICK HERE" -
