码迷,mamicode.com
首页 > Web开发 > 详细

js运行机制

时间:2017-08-20 10:02:12      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:div   set   nbsp   执行顺序   out   pre   题目   func   为什么   

先来看一道题目然后再来详细的说明js的运行机制,下面的一段代码执行顺序是什么

         console.log(1);
         setTimeout(function () {
             console.log(2);
         }, 0);
         console.log(3);
         console.log(4);

 

测试得到的结果是1,3,4,2,至于为什么会这么执行,我们来看下面的内容

 

js运行机制

标签:div   set   nbsp   执行顺序   out   pre   题目   func   为什么   

原文地址:http://www.cnblogs.com/LO-ME/p/7398538.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!