Statements
for await...of
Sequentially awaits iteration results in an async context (or a module supporting top-level await). Uses async iteration when available, otherwise adapts synchronous iteration.
Formal Syntax & Structure
javascript syntaxjavascript
for await (const value of iterable) { /* body */ }Working Example
Example Snippetjavascript
(async()=>{let sum=0;for await(const x of [1,2])sum+=x;console.log(sum);})();