Sitemap
Better Programming

Advice for programmers.

Member-only story

Understanding async-await in JavaScript

8 min readJul 20, 2018

--

Photo by Qusai Akoud on Unsplash

async and await are extensions of promises. If you are not comfortable with the basics of promises, please spend some time understanding promises before reading further.

I am sure that many of you are using async and await already. But, I think it deserves a little more attention.

Here is a small test: If you can’t spot the problem with the below code, read on.

We will revisit this code block later, once we have gone through async-await basics. As always, Mozilla docs is your friend. Especially check out the definitions.

From MDN:

“An asynchronous function is a function which operates asynchronously via the event loop, using an implicit Promise to return its result. But the syntax and structure of your code using async functions is much more like using standard synchronous functions.”

--

--

Responses (22)