JS Built-ins
AsyncPatternsadvanced

Promise executor runs synchronously

πŸ“– Usage Example
let ran = false;
new Promise(resolve => { ran = true; resolve(); });
// ran is true immediately

The executor function runs synchronously when the Promise is created.

Executor Synchronicity

The executor function passed to new Promise() runs immediately and synchronously.

Challenge: Verify that the executor runs synchronously before the constructor returns.

πŸ’‘ Hints (3)
  • β€’ The executor function runs synchronously.
  • β€’ The executor runs before .then() callbacks.
  • β€’ Use this to understand the Promise execution model.