en.javascript.info
en.javascript.info copied to clipboard
await async
In https://javascript.info/async-await it states
Let’s emphasize: await literally suspends the function execution until the promise settles, and then resumes it with the promise result. That doesn’t cost any CPU resources, because the JavaScript engine can do other jobs in the meantime: execute other scripts, handle events, etc.
This is not clear enough. It must clarify that it just suspends the async function in which the await resides. It doesn't suspend the outer method if that doesn't await.
Therefore note that in this example "start 1" and "start 2" are logged before the resolution is logged.