Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • 宏任务和微任务

宏任务和微任务

宏任务

setTimeout setInterval Ajax DOM事件

微任务

Promise async/await

执行顺序

微任务执行时机比宏任务要早

console.log(1)

setTimeout(() => {
  console.log(2)
})

Promise.resolve().then(() => {
    console.log(3)
})
console.log(4)

答案 :

1
4
3
2
Edit this page
最近更新: 2025/6/27 02:24
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人