JavaScript · Senior · Question 3 of 75
Does the new Promise(executor) executor function run synchronously?
new Promise(() => console.log("A"));
console.log("B");- ✓Correct answer: Yes:
Ais printed, thenB - 2No:
Bis printed, thenA - 3No:
Aisn't printed untilresolveis called
Explanation
The executor is called right away in the constructor. Only then/catch/finally callbacks are asynchronous - they always run as microtasks, even if the promise is already settled. This guarantees a predictable code order.