求教: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,那微任务队列会不会爆满影响浏览器性能?怎么解决?
#前端##面试题目#
全部评论
那设置一个阈值呗
点赞 回复
分享
发布于 2021-08-13 23:34

相关推荐

点赞 2 评论
分享
牛客网
牛客企业服务