Hint
Sequential awaits for independent operations multiply latency. Promise.all is the correct tool when operations are independent β latency = max of all, not sum.
async function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function sequential() {
const start = Date.now();
await delay(100);
await delay(100);
await delay(100);
return Date.now() - start;
}
async function parallel() {
const start = Date.now();
await Promise.all([delay(100), delay(100), delay(100)]);
return Date.now() - start;
}
sequential().then(ms => console.log('sequential:', ms > 250));
parallel().then(ms => console.log('parallel:', ms < 150));sequential: true parallel: true
Explanation: Sequential awaits run one after another: ~300ms total. Promise.all fires all three simultaneously β they overlap β ~100ms total. sequential > 250ms = true, parallel < 150ms = true.
Key Insight: Sequential awaits for independent operations multiply latency. Promise.all is the correct tool when operations are independent β latency = max of all, not sum.