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

xiaoxiao2021-02-28  105

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

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

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

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 <html> <head> <title> this 关键字_函数调用</title> <meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" ></head> <body>   <input type= "text" id= "test1" name= "firstname" value= "" /> <input type= "text" id= 'lastname' name= 'lastname' 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" id="test1" name="firstname" value="" /> }, 'lastname' : function () { document.getElementById( 'lastname' ).value = "ying" ; } }; console.log(testobj); /** 打印对像**/   testobj.firstname(); testobj.lastname(); </script> </html>
转载请注明原文地址: https://www.6miu.com/read-47437.html

最新回复(0)