Node.js ยท Chapter 1 of 43

Node.js Introduction

Node.js is a runtime that lets you run JavaScript outside the browser, on a server. It uses Google Chrome's V8 engine and is built for fast, scalable network applications.

With Node.js, JavaScript became a full-stack language โ€” the same language you use in the browser can now power your backend, APIs, and command-line tools.

Why Node.js?

Node.js uses a non-blocking, event-driven model that makes it lightweight and efficient, perfect for data-intensive real-time applications like chat apps, APIs and streaming services.

What can it do?

Node.js can generate dynamic page content, create, open, read, write, delete and close files on the server, collect form data, and add, delete and modify data in a database.

Example 1 (javascript)
console.log("Hello from Node.js!");
console.log(process.version);
Output
Hello from Node.js!
v20.11.0

Running this file with `node app.js` prints output to the terminal, not a browser console.

Example 2 (javascript)
console.log(typeof window);
Output
undefined

Unlike browsers, Node.js has no `window` object because there's no browser page.

Key points

  • Node.js runs JavaScript outside the browser using the V8 engine.
  • It is event-driven and non-blocking, great for scalable apps.
  • Node.js turns JavaScript into a full-stack language.
  • It powers APIs, CLIs, real-time apps and more.
๐Ÿ’ก Note: Node.js is not a language or framework โ€” it's a JavaScript runtime environment.

๐Ÿ“ Quick Quiz

1. What engine does Node.js use?

2. Node.js is best described as:

3. Which object exists in browsers but NOT in Node.js?