เมื่อฉันทำการดีบักรหัสฉันมักจะตรวจสอบการดำเนินการของรหัส JS โดยใช้การแจ้งเตือนในบล็อกรหัส วันนี้ฉันยังเห็นเพื่อนที่ใช้ฟังก์ชั่นคอนโซลล็อกเพื่อพิมพ์ฟังก์ชั่นตัวแปรวัตถุและการใช้คอนโซล log ถูกบันทึกไว้ด้านล่าง ไวยากรณ์เฉพาะคือ:
console.log ("ค่า:", fn);console.log () สามารถเอาต์พุตตัวแปรฟังก์ชั่นอาร์เรย์วัตถุ ฯลฯ
<html> <head> <title> การเรียกคีย์เวิร์ดนี้ </title> <meta http-equiv = "เนื้อหาประเภท" content = "text/html; charset = gb2312"> </head> <body> value = ''> </body> <script type = "text/javascript"> var testobj = {'id': 1, 'เนื้อหา': 'ทดสอบ', '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 ("value", this.content); console.log ("ค่าของวัตถุคือ:", test1); // ค่าของวัตถุคือ: <อินพุต type = "text" id = "test1" name = "firstName" value = "" />}, 'LastName': function () {document.getElementById ('LastName'). value = "ying"; - console.log (testobj);/ ** พิมพ์วัตถุ **/ testobj.firstname (); testobj.lastname (); </script> </html>