The js debugging tool console.log of method looks at the execution of the js code
- 2020-03-30 03:38:35
- OfStack
When I was debugging the code, I usually used alert in the code block to check the execution of js code. Today, I also saw some friends use the console.log function to print out functions, variables and objects.
console.log(" A value of :",fn);
Console.log () can output variables, functions, arrays, objects, and more
<html>
<head>
<title>this The keyword _ A function call </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(" The value of the object is: ",test1);//The value of the object is: <Input type="text" id="test1" name="firstname" value="" />
},
'lastname': function() {
document.getElementById('lastname').value = "ying";
}
};
console.log(testobj);
testobj.firstname();
testobj.lastname();
</script>
</html>