What is the result of executing the following code snippet in a modern browser environment? const p = Promise.resolve(); p.then(() => console.log(1)); queueMicrotask(() => console.log(2)); setTimeout(() => console.log(3), 0);
Key points
- Promises and queueMicrotask share the same microtask queue.
- setTimeout is a macrotask.
- Microtasks are always processed before the next macrotask.
Ready to go further?
