Node.js: getting started

Lesson 01 · 10 min

The runtime and the event loop

One thread, a task queue, and no stopping to wait.

Node.js is the V8 engine from Chrome plus access to files, the network, and the process. There's no DOM or window. Your code runs on one thread, and slow operations (disk, network, database) are handed to the system while Node carries on with other work.

Execution order
AI

You can ask about this rule«Don't block the thread»

  • node app.js runs a file. node with no arguments starts a REPL.
  • process.env holds environment variables, process.argv the command-line arguments.
  • Microtasks (Promises) run before timers.
AI

You can ask about this point«Lesson summary»

Check

Lock it in before you move on

  1. 1. Is there a document in Node.js?

  2. 2. A 3 s synchronous loop in a request handler…

  3. 3. What runs first: setTimeout(..., 0) or Promise.then?

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice