JavaScript and Asynchronous Operations

Marcos Gonçalves
NERDJACKING
Published in
1 min readMay 26, 2021

Do you really do it right?

Unlocking the full power of async ops on JavaScript

Asynchronous operations are not a mystery but there is a catch: do you really take the benefits from it?

Know how to properly control the async flow is an important benchmark in a developer career and it can easily be the difference between a “yes” or “no” during a technical interview or even in the thing that can boost the performance of your app.

So let’s get some concepts right:

1 — All async functions returns a Promise, so you have available the methods .then(), .catch() and .finally().

2 — Async functions when called, are executed in the background. Once resolved (finished), it will call the callback function to let you know about the result (fulfilled or rejected).

3 — The “await” keyword blocks the code execution on that line until the Promise is settled (fulfilled or rejected); only then, the next line will run.

So, what are the actual effects we want to have when using async ops?

That’s simple: performance.

And it’s done by running all Promises in the background in a non-blocking way; optimally using Promise.allSettled() method.

And this is how you do

Got something on your mind? Let us know in the comments 💪

--

--

Marcos Gonçalves
NERDJACKING

Lead Engineer | Architect | Developer Advocate | 12+ years of experience. Also a lover of a good beer in his spare time.