时间:2021-05-26
我之前在调试代码的时候,跟砸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>声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
复制代码代码如下://建立app.js页面//一:页面代码console.log("log信息");//在页面中执行(nodeapp.js)这个文件会在控制台中
在js中,延迟执行函数有两种,setTimeout和setInterval,用法如下:functiontestFunction(){Console.log('h
前言我们知道js是单线程执行的,那么异步的代码js是怎么处理的呢?例如下面的代码是如何进行输出的:console.log(1);setTimeout(funct
本文实例讲述了JS中捕获console.log()输出的方法。分享给大家供大家参考。具体分析如下:我们知道console.log()可以将信息输出到debugg
具体代码如下所述:Document//js函数的书写functionmyFunction(){console.log("你好");}//左边是funcion关键