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.
In the 3rd and 4th code blocks, the async function and the normal function both have the async keyword before them. Is that right?
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.
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.
In the 3rd and 4th code blocks, the async function and the normal function both have the async keyword before them. Is that right?
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.
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.