When is the body of a Promise executed?

Immediately, yes, by specification.

From the MDN:

The executor function is executed immediately by the Promise implementation, passing resolve and reject functions (the executor is called before the Promise constructor even returns the created object)

Here it is in the ECMAScript specification (of course harder to read…): http://www.ecma-international.org/ecma-262/6.0/#sec-promise-executor

This guarantee may be important, for example when you’re preparing several promises you then pass to all or race, or when your executors have synchronous side effects.

Leave a Comment