DEV Community

Discussion on: How does asynchronous JavaScript work behind the scenes?

Collapse
 
twelve profile image
nntwelve

Thank for this very nice article. I've learned a lot from this.
But I have a thing to contribute that is the** (macro)task** queue is high priority than microtask queue. Following your example in . The reason of the setTimeout ran after Promise is it was sent to the (macro)task queue and execute in the next iteration (Tasks added to the queue after the iteration begins will not run until the next iteration.). It is different with microtask queue when execution of microtasks continues until the queue is empty—even if new ones are scheduled in the interim.