Reputation: 77
When many async functions have been queued up, will their callbacks execute sequentially or concurrently?
Upvotes: 2
Views: 121
Reputation: 529
They are run sequentially, even though they may be queued up in an asynchronous manner.
Events are triggered in a multi-threaded area of the browser called Web APIs. Following an event (e.g. XHR request) being triggered asynchronously, an event loop synchronously selects the event's callback onto JavaScript’s single-threaded call stack to be executed.
Dan Martensen offers a nice detailed writeup on the subject
Upvotes: 2