I realized that the requestAnimationFrame callback also pushed to a queue like the promise, does anyone explain the code, why console.log(2)
is running before console.log(1)
requestAnimationFrame(() => {
console.log(1)
})
const end = Date.now() + 2000;
while (Date.now() < end) {
}
console.log(2)