Async and await are syntactic sugars for promise nesting. Where await will block the main thread until the promise is resolved. Can you guess the output of below snippet? You’re wrong, the output is 1. Because an async function always returns a promise and rather resolving the promise in above example we are trying to extract the value out of it.

2m read timeFrom javascript.plainenglish.io
Post cover image
Table of contents
What are async and await?Can you guess the output of below snippet?Why is it so?What’s the solution?A better approach
6 Comments

Sort: