Skip to main content
code•what happens-next•javascript
0s
+20 XP

JavaScript Microtask vs Macrotask Event Loop

What is the exact order of console logs when this script executes in the JavaScript event loop?

javascript
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');
Exit to Challenges