The Event Loop
Synchronous code runs first, then microtasks (promises), then timers.
Example
console.log("1 sync");
setTimeout(() => console.log("4 timeout"), 0);
Promise.resolve().then(() => console.log("3 promise"));
process.nextTick(() => console.log("2 nextTick"));Result
1 sync 2 nextTick 3 promise 4 timeout
Exercise
Runs before promises.
process.(fn)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.