Skip to content

What Is Node.js? Running JavaScript Outside the Browser

Programming Node.js Difficulty 1/5

Beginning of the lesson

What Is Node.js?

Running JavaScript outside the browser

Big Idea: For a long time, JavaScript could only run inside a web browser. Node.js changed that. It is a runtime that lets you run JavaScript directly on your computer or on a server, with no browser at all.
By the end you will be able to:
  • explain what Node.js is (a JavaScript runtime),
  • say why JavaScript "left the browser" and what Node is used for,
  • run a JavaScript file yourself with the node command.

1. JavaScript used to live only in the browser

JavaScript was born in 1995 to make web pages come alive: clicking buttons, checking forms, showing pop-ups. To do that, it ran inside the browser (Chrome, Firefox, Safari). The browser gave it special tools like document (the page) and window (the browser tab).

But that also meant JavaScript was trapped. It could not read a file on your computer, or answer requests from other computers, because a web page is not allowed to do those things for safety reasons.

2. Node.js is a JavaScript runtime

A runtime is the program that actually runs your code. Node.js (created in 2009) is a runtime that runs JavaScript. It uses the same fast engine that powers Google Chrome, called V8, and wraps it so JavaScript can work outside a browser.

With Node, JavaScript gains new powers the browser never gave it: it can read and write files, talk to databases, and act as a server that answers requests from the internet.

JavaScript Browser (web pages) Node.js (your computer)
The same JavaScript language now runs in two places: inside a browser and inside Node.js on a computer or server.

Important: Node.js is not a new language. The language is still JavaScript. Node is just a new place to run it.

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers