Ketika saya men -debug kode, saya biasanya memeriksa eksekusi kode JS dengan menggunakan peringatan di blok kode. Hari ini saya juga melihat seorang teman menggunakan fungsi Console.log untuk mencetak fungsi, variabel, objek, dan penggunaan Console.log direkam di bawah ini. Sintaks spesifiknya adalah:
console.log ("nilai:", fn);Console.log () dapat mengoutput variabel, fungsi, array, objek, dll.
<html> <head> <title> Kata kunci ini. Panggilan Fungsi </itement> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"> </head> <body> <input type = "text" id = "test1" name = "firstName" value = "" " value = ''> </body> <script type = "text/javascript"> var testoBj = {'id': 1, 'Content': 'test', 'firstName': function () {var eLeFirst = document.geteLementById ('test1'); //document.getElementById('firstname').value = "zhang"; //document.getElementById("test1").value = this.content; //document.getElementById("test1").setAttribute("value" ,"zhang "); //this.content = val; ELeFirst.setAttribute ("nilai", this.content); console.log ("Nilai objek adalah:", test1); // Nilai objek adalah: <input type = "text" id = "test1" name = "firstName" value = "" />}, 'LastName': function () {document.getElementById ('lastName'). Value = "ying"; }}; console.log (testobj);/ ** cetak objek **/ testobj.firstname (); testobj.lastname (); </script> </html>