DEV Community

Discussion on: Simple Explanation of Async-Await in Javascript

Collapse
 
wande_sho profile image
admin.php

Nice and simple introduction. I never had a real-life use case for this, but with this explanation I can think of new ways to implement this. Thanks.

Also, I think (and I may be wrong) that you've made a mistake though.

  1. In the 3rd and 4th code blocks, the async function and the normal function both have the async keyword before them. Is that right?

  2. In the final code block, function getB( ) doesn't have the async keyword, whereas you mention that the await keyword can only be used with async functions.

Collapse
 
lindaojo profile image
Linda

Thank you, I have fixed the first issue.

Await can only be used "within" an async function. getB() does not have the async keyword because it doesn't use await within it. I hope that's clear.