
for await…of Loop – Async iteration: awaits each promise from an async iterable before running the loop body.
๐ Syntax
for await (const value of asyncIterable) {
// awaited value
}
๐งช Example
async function* makeAsync() {
yield 'A';
yield Promise.resolve('B');
}
for await (const v of makeAsync()) {
console.log(v);
}
Comments
Post a Comment