From 8269f1792136d54d29f88ee318d020815d011f5b Mon Sep 17 00:00:00 2001 From: Juraj Kapsz Date: Tue, 14 Jul 2026 21:50:40 +0200 Subject: [PATCH] docs: clarify Promise.all execution behavior in part4b - This update tries to clarify that `Promise.all` **waits for promises to settle** rather than executing them, as promises are already running when they are passed to `Promise.all`. - Also clarify that sequential execution is achieved by using `await` inside a `for...of` loop, not by merely creating or handling promises inside the loop, such as: ```js for (const note of helper.initialNotes) { new Note(note).save().then(() => { // handle success }); } ``` --- src/content/4/en/part4b.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/4/en/part4b.md b/src/content/4/en/part4b.md index 6da9ce905dc..f546d75b004 100644 --- a/src/content/4/en/part4b.md +++ b/src/content/4/en/part4b.md @@ -888,7 +888,7 @@ The [Promise.all](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere > The returned values of each promise in the array can still be accessed when using the Promise.all method. If we wait for the promises to be resolved with the _await_ syntax const results = await Promise.all(promiseArray), the operation will return an array that contains the resolved values for each promise in the _promiseArray_, and they appear in the same order as the promises in the array. -Promise.all executes the promises it receives in parallel. If the promises need to be executed in a particular order, this will be problematic. In situations like this, the operations can be executed inside of a [for...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) block, that guarantees a specific execution order. +`Promise.all` waits for the promises it receives to settle concurrently. If the operations need to happen in a particular order, this would be problematic. In situations like this, the operations can be executed in a [for...of loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) using the `await` operator, which ensures that each operation completes before the next one starts. ```js beforeEach(async () => {