1.Predict the order
IntermediatePredict the output of this code, then run it:
console.log("1");
setTimeout(() => console.log("2"), 0);
Promise.resolve().then(() => console.log("3"));
console.log("4");Show hint
Synchronous code first, then microtasks (promises), then timers.
Show solution
console.log("1");
setTimeout(() => console.log("2"), 0);
Promise.resolve().then(() => console.log("3"));
console.log("4");1
4
3
2