JS ⟩ async ⟩ await ⟩ promises ⟩ sequentially
await multiple promises sequentially.
replit:awaiting multiple promises, require: measureTime(), futureValue()
async function f() { // ⭐ awaiting multiple promises "sequentially" const a = await futureValue(20, 2); // in 2 sec const b = await futureValue(30, 4); // in 4 sec return a + b; }
results
measureTime(f); // ⭐ 6.00 sec : f() -> 50
Promises in parallel
chaining Promises (in series)
JS.info ⟩ async/await
Last updated 1 year ago