js调试工具console.log()方法查看js代码的执行情况

以往都是使用alert的方式查看js代码的执行情况,今天看到有朋友使用console.log函数打印输出函数,变量,对象,下边就console.log的使用情况进行记录

我之前在调试代码的时候,跟砸js代码执行情况,一般都是通过在代码块中使用alert的方式查看js代码的执行情况,今天也是看到有朋友使用console.log函数打印输出函数,变量,对象,下边就console.log的使用情况进行记录,具体的语法是:

console.log("值为:",fn);

console.log()能够输出变量,函数,数组,对象等等

<html> <head> <title>this关键字_函数调用</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> <body> <input type="text" value="" /> <input type="text" 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("value",this.content); console.log("对象的值为:",test1);//对象的值为:<input type="text" value="" /> }, 'lastname': function() { document.getElementById('lastname').value = "ying"; } }; console.log(testobj);/** 打印对像**/ testobj.firstname(); testobj.lastname(); </script> </html>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgspxs.html