Runtime and core tooling · Lesson 1 of 18
What is Node.js?
V8, libuv and built-ins, and why Node is not a browser on the server.
Node.js is a JavaScript runtime outside the browser. V8 executes JavaScript, while Node adds server APIs for files, networking and processes. libuv supplies the event loop and cross-platform I/O. There is no DOM or window because no web page exists.
JavaScript code
V8 executes
Node built-ins
libuv + operating system
const os = require("node:os")
console.log("runtime:", "Node.js")
console.log("cpus available:", os.cpus().length > 0)Node excels at I/O-heavy work such as APIs, chat and tools because its JavaScript thread does not wait on network I/O. It is not automatically faster for CPU-heavy computation: a long loop blocks the event loop and delays every request.
Quick question
Which API exists in a browser but not in Node by default?
Exercise
Write describeRuntime(hasWindow) returning browser for true and node for false, then print false's result.
Expected output: node
function describeRuntime(hasWindow) {
}
console.log(describeRuntime(false))Learn more from
Played 0 of 2 games
Sign in to save your progress and earn XP.