Await is only valid in async function #184
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
There is two cases to use
For the first case, the specification is currently in progress and will come in the future For the second case, a function that call a
If you care about the result of the |
Beta Was this translation helpful? Give feedback.
-
This is more like a question. A top-level |
Beta Was this translation helpful? Give feedback.
await
is syntax sugar aroundPromise
There is two cases to use
await
:For the first case, the specification is currently in progress and will come in the future
For the second case, a function that call a
Promise
must :callback
that will be executed after thePromise
finished the asynchronous taskPromise
do side-effectPromise
If you care about the result of the
Promise
and want to wait before executing others instructions, that means that this function will wait for an asynchronous task, and beasync
hronous as well, that why theasync
keyword is required