async/await vs callback resolution order, given shared asynchronicity

If async/await & callbacks are both asynchronous, why are async/await resolved before callbacks?

For example (hypothetical, in practice its obviously not so cut-and-dry)

// classic callback
doSomething("./some-path", (err, data) => {...})

// This resolves with higher priority
await someAsyncFunction()

>Solution :

In short, callbacks go to the end of the line in the regular job queue. async/await goes through the message queue, which is akin to a "fast pass" lane at an amusement park.

This article has some great examples and does a pretty good job covering this exact topic.

Leave a Reply