use*_*589 2 javascript debugging
当我跑进去的时候 console
console.log("1");
setTimeout(function(){console.log("2");},3000);
console.log("3");
setTimeout(function(){console.log("4");},1000);
Run Code Online (Sandbox Code Playgroud)
我明白了:
3之前和之后用蓝色写的数字是多少4?
该数字是您执行的最后一个语句的返回值.
console.log("1");
setTimeout(function(){console.log("2");},3000);
console.log("3");
setTimeout(function(){console.log("4");},1000);//-- the return of this call
Run Code Online (Sandbox Code Playgroud)
第一行打印1,返回值是undefined被丢弃
第二行创建3秒计时器,返回值是计时器参考但是再次被丢弃
第三行打印3,返回值undefined被丢弃
,最后一行创建1秒计时器,因为这是最后一个语句,所以语句的结果打印
1秒后4打印
然后最后2打印
| 归档时间: |
|
| 查看次数: |
58 次 |
| 最近记录: |