V8 adds support for top-level await
I think async&#x2F;await probably makes more sense in a typed language, where a compiler can tell you when you&#x27;re missing an await, or at least warn you about not dealing with potential side effects and error handling. For something like JavaScript, it&#x27;d make more sense to me to have the runtime always and implicitly await the result of async functions, and instead make developers explicitly say when they wish for the result to be async. For example, instead of:<p><pre><code>    const data = await fetch()
    push(someData) &#x2F;&#x2F; async, runs in the background
</code></pre>
You would do:<p><pre><code>    const data = fetch() &#x2F;&#x2F; Runtime detects promise and awaits result
    async push(data) &#x2F;&#x2F; the async keyword would return a promise and execute the push function asynchronously, allowing the next line to execute
</code></pre>
In this fantasy world the &quot;await&quot; keyword would work anywhere and as you&#x27;d expect – awaiting the result of any promise:<p><pre><code>    const data = fetch() &#x2F;&#x2F; implicitly await
    await async push(data) &#x2F;&#x2F; this would also be &quot;synchronous&quot; in that it suspends execution of subsequent code until `push` fulfills or rejects the promise, and so it&#x27;d have the same effect as implicit await
</code></pre>
Point is you&#x27;d probably await that promise elsewhere, so you&#x27;d actually store away the return value of the `async` call and later on you&#x27;d `await`, or another example would be to await a block.<p>Promise rejections in implicit awaits would halt execution, just like a sync function throwing an error, so you wouldn&#x27;t &quot;miss&quot; an error somewhere because runtimes swallow promise rejections. (Well, at least Node wised up eventually.)<p>This means there&#x27;d be no difference in function declaration between sync and async functions, it&#x27;d be determined by whether they return a promise or not which I <i>think</i> should be possible to statically determine by a JIT compiler in most cases, so not adding too much (if any) overhead.<p>Kind of a half baked thought, but point is I always felt the async&#x2F;await thing was kind of backwards in JavaScript.