en.javascript.info icon indicating copy to clipboard operation
en.javascript.info copied to clipboard

await async

Open yaron-tomer opened this issue 2 years ago • 0 comments

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.

yaron-tomer avatar Aug 27 '23 21:08 yaron-tomer