1. Concept library
  2. Backend with Node.js
  3. Module 1: The Node.js runtime

Concept

The event loop

Node runs your JavaScript on one thread and hands slow work, such as network and disk I/O, to the system, picking up the results as callbacks. The event loop is the queue that decides what runs next.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain how one thread handles many connections through the event loop
  2. Predict the order of logs across setTimeout, promises and nextTick
  3. Spot the CPU-heavy work that blocks every other request

In practice

A few lines that show The event loop doing its job.

JavaScript
console.log("start");
setTimeout(() => console.log("timer"), 0);
Promise.resolve().then(() => console.log("microtask"));
process.nextTick(() => console.log("nextTick"));
console.log("end");

// start, end, nextTick, microtask, timer

The common mistake

Watch for

Doing CPU-heavy work, such as hashing or parsing a huge file, on the main thread. Every other request waits until it finishes. Move it to a worker thread or stream it.

How it stays learned

Once a session shows you understand The event loop, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled

Where it leads

Topics that build on The event loop.

Next in the moduleModules in Node →