NERDJACKING
Published in

NERDJACKING

JavaScript and Asynchronous Operations

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 💪

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store