Jon Newton

March 4, 2021

Synchronous asynchronous-functions with async/await


MDN never disappoints and I find this part of their async/await guide the most interesting:

Async/await makes your code look synchronous, and in a way it makes it behave more synchronously… This means that your code could be slowed down by a significant number of awaited promises happening straight after one another.

Here’s a slightly modified example taken from the article. Each test creates and resolves 3 promises. The slow version will resolve each promise in sequence while the fast version allows each promise to run simultaneously.

https://jsfiddle.net/newtnik/bt6oqjeL/18/

About Jon Newton

Pandemic programming and beyond! My Link Tree