事件循环的练习题

练习题1:

console.log(1)

async function async1(){

await async2()

console.log(2)

}

async function async2(){

console.log(3)

}

async1()

setTimeout(function(){

console.log(4)

},0)

new Promise(resolve=>{

console.log(5)

resolve()

}).then(function(){

console.log(6)

}).then(function(){

console.log(7)

})

console.log(8)

结果:1,3,5,8,2,6,7,4

练习题2:

setTimeout(()=>{

console.log(1)

})

console.log(2)

setTimeout(()=>{console.log(3)},0)

setTimeout(()=>{console.log(4)},100)

console.log(5)

new Promise(resolve=>{

console.log(6)

resolve()

}).then(function

剩余60%内容,订阅专栏后可继续查看/也可单篇购买

前端面试题 文章被收录于专栏

前端面试的一些常问问题、问题的具体实现(可直接运行)以及底层原理

全部评论

相关推荐

karis_aqa:和hr没关系,都是打工的
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务