As my understanding about event loop, event loop will push the callbacks into the callstack, but for example, the following code, the sync code console.log(2)
is running after the click event handler, why is that?
console.log(1)
document.body.addEventListener('click', () => {
console.log(3)
})
document.body.click()
console.log(2)