# 什么是Event Loop(事件循环机制)

# 如下代码,写出它们结果打印的先后顺序,并分析出原因

console.log("AAAA");
setTimeout(() => {
  console.log("BBBB")
}, 1000);
const start = new Date();
while (new Date() - start < 3000) {}
console.log("CCCC");
setTimeout(() => {
  console.log("DDDD")
}, 0);
new Promise((resolve, reject) => {
  console.log("EEEE")
  foo.bar(100)
})
  .then(() => console.log("FFFF"))
  .then(() => console.log("GGGG"))
  .catch(() => console.log("HHHH"));
console.log("IIII");
Last Updated: 5/31/2021, 1:56:14 PM