eventloop重点:
同步任务先执行,然后是异步任务
异步任务又分宏和微
宏任务 setTimeout 最低
微任务 promise 优先级高
console.log(1); // 同步任务 (function(){ // 同步任务 console.log(2) })(); setTimeout(function () { // 宏任务 console.log(3) }); new Promise(function (a, b) { // 微任务 console.log(4); a() }).then(function () { console.log(6) }); console.log(7) // 同步任务 //执行顺序为 1 2 4 7 6 3