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

2019-12-21,,,

我之前在调试代码的时候,跟砸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" 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>

您可能感兴趣的文章:

  • Javascript之Math对象详解
  • JavaScript中Math对象使用说明
  • JavaScript中Math对象的方法介绍
  • JavaScript中Math对象方法使用概述
  • 使用js Math.random()函数生成n到m间的随机数字
  • javascript Math.random()随机数函数
  • 在javascript中随机数 math random如何生成指定范围数值的随机数
  • JavaScript调试技巧之console.log()详解
  • JS调试必备的5个debug技巧
  • js调试工具Console命令详解
  • javascript代码调试之console.log 用法图文详解
  • JavaScript Math对象和调试程序的方法分析

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

下载本文的Word格式文档,以方便收藏与打印。