Promise or timer first?
Take your time, follow the code and check your understanding.
The codeNode.js requests and async
console.log("start");
setTimeout(() => console.log("timer"), 0);
Promise.resolve().then(() => console.log("promise"));
console.log("end");Your answer4 min · no timer
Show solution and explanation
Synchronous statements finish first. The resolved promise callback runs as a microtask before the timer callback in this example.
start, end, promise, timer