DEV Community

Amalks920
Amalks920

Posted on

Explain X Like I'm Five

Explain VPN Like I'm Five

Top comments (2)

Collapse
 
amalks920 profile image
Amalks920

Explain Async,Await in JavaScript Like I'm Five

Collapse
 
deezy profile image
DEE

It's a more elegant way of handling asynchronous actions. The default way to handle promises in Javascript is through callbacks. It seems approachable when it's just a few promises and callbacks you're dealing with. It gets really nasty when it becomes too many aka Pyramid of Doom . That's where Async/Await comes to the rescue where, in a function marked as async , you can simply wait for the result of an asynchronous action or a promise by using the await keyword.

It allows you write asynchronous code in a "synchronous-like" manner hence enhancing code maintenability and readability.