首页 > 求教:JS事件循环问题
头像
风林小牛
编辑于 2021-08-11 14:39
+ 关注

求教:JS事件循环问题

new Promise(function (resolve) {
  console.log('4')
  resolve()
}).then(function () {
  console.log('6')
})
new Promise(function (resolve) {
  console.log('4')
  resolve()
}).then(function () {
  console.log('6')
})
new Promise(function (resolve) {
  console.log('4')
  resolve()
}).then(function () {
  console.log('6')
})
new Promise(function (resolve) {
  console.log('4')
  resolve()
}).then(function () {
  console.log('6')
})

面试被问到的问题:我们都知道then会加到微任务队列,像上面这种情况,如果我有1万个new Promise,那微任务队列会不会爆满影响浏览器性能?怎么解决?

更多模拟面试

全部评论

(1) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

热门推荐