Ollie
Ollie

Reputation: 77

Javascript (ES6) asynchronous callback execution

When many async functions have been queued up, will their callbacks execute sequentially or concurrently?

Upvotes: 2

Views: 121

Answers (1)

DoloMike
DoloMike

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

Related Questions