Async/Await For Beginners - Understanding Asynchronous Code in Javascript
Async/Await For Beginners - Understanding Asynchronous Code in Javascript
Menu
1 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
What is Asynchronous
Programming?
To truly understand why we need things like Async / Await,
we have to take a look at JavaScript’s core concepts. At its
base, JavaScript is a synchronous programming language.
This means it is single-threaded. Only one operation can be
executed at a time. I visualized in the following graphic why
this can lead to problems.
2 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
3 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
So, the main reason why the Async / Await method made its
way is that it makes asynchronous and synchronous code
more or less indistinguishable. That, in turn, brings a new
level of clarity and simplicity to handling asynchronous code
which wasn’t there before.
4 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
Then, we do the same thing for the json call in line 4 and
finally, we return the received data in line 5. It’s easy as that!
5 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
6 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
function body, we can then work with the actual received data
of our fetchData call.
91 claps
7 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
WRITTEN BY
Konstantin Münster
Follow
Follow
8 of 9 1/14/20, 3:58 PM
Async/Await for Beginners— Understanding As... https://googleweblight.com/i?u=https://medium...
Vue Angular
Node Archive
9 of 9 1/14/20, 3:58 PM