We all know that JavaScript is Synchronous which means that it has an event loop that allows you to queue up an action.
But thereβs a lot of functionalities in our program which make our code Asynchronous.
One of them is the Async/Await functionality.
Async
It operates asynchronously via the event loop. Async functions will always return a value.
It makes sure that a promise is returned and if it is not returned then JavaScript automatically wraps it in a promise which is resolved with its value.
Await
Await function is used to wait for the promise.
It could be used within the async block only.
It makes the code wait until the promise returns a result.
It only makes the async block wait.
Notice that the console prints 2 before the βHello Worldβ. This is due to the usage of the await keyword.
Supported Browsers: The browsers supported by Async/Await Function are listed below:
π Google Chrome
π Firefox
π Apple Safari
π Opera
Thank you for reading!
Hey, I'm Roshane π
I tweet daily on JavaScript, Web Development, and Developer Resources.
If you found this thread useful
π Follow me (kendrip_) β
π Retweet it π
π Leave a like π
Thank you for the support fellow developers!
Top comments (0)