This is a very common interview question, but it should include all the knowledge of event Loop. Please first think about the output and then run it yourself to see why. Daniel, please ignore

console.log(1)
setTimeout(function () {
	console.log(2)
}, 1000)
async function test(){
  console.log(3)
  await setTimeout(() => {
    console.log(4)
  }, 0)
  console.log(5)
}
test()
new Promise(function (resolve, reject) {
    console.log(6)
    setTimeout(function () {
        console.log(7)
    }, 500)
    resolve()
}).then(function (res) {
    console.log(8)
})
console.log(9)
Copy the code