What Is Node.js?
JavaScript with a New Home
Most people meet JavaScript inside a web browser. You visit a website, and JavaScript makes the page come alive: menus open, forms check your typing, data loads without a refresh.
But JavaScript is just a language. A language needs something to run it — a program that reads your code and makes it do things. That program is called a runtime. Browsers come with one built in.
Node.js is a second runtime for JavaScript. It takes the same language you already know from the browser and lets you run it on a computer directly — with no browser and no web page in sight.
So a short definition: Node.js is a JavaScript runtime that runs outside the browser. That's the whole idea. Everything else in this tutorial builds on it.
Why Does This Matter?
Before Node.js appeared in 2009, JavaScript was trapped. It could only live inside a browser. If you wanted to write the server side of a website — the part that stores data and answers requests — you needed a different language, like Python, Java, or PHP.
Node.js changed that. Suddenly one language could do both jobs:
- Front end (runs in the browser): what the user sees and clicks.
- Back end (runs on a server): storing data, handling logins, answering requests.
Teams no longer need to switch languages between the two halves of a project. That is the main reason Node.js became so popular.
The Engine Under the Hood
Node.js doesn't read JavaScript by itself. It borrows the browser's engine and uses it for you.
Google's Chrome browser contains a program called V8. V8's job is to take JavaScript text and turn it into fast instructions your computer's chip can execute. Node.js takes V8 out of Chrome, wires it to your computer's file system and network, and hands you the controls.
You can picture it like this:
Show diagram source
flowchart LR
A["Your JavaScript code"] --> B["V8 engine"]
B --> C["Node.js"]
C --> D["Your computer: files, network, memory"]The key point: the JavaScript you write is the same. What changes is the surroundings — what your code can touch.
Browser JavaScript vs. Node.js
Because the surroundings differ, the tools available to your code differ too.
| Capability | In the browser | In Node.js |
|---|---|---|
| Change the page (DOM) | Yes | No |
| Read and write files | No | Yes |
| Open a network server | No | Yes |
| `alert()` popups | Yes | No |
| Same language syntax | Yes | Yes |
In short: no web pages, but full access to the machine. Node.js can read your files, talk to databases, and accept network connections — things a browser sandbox deliberately blocks for safety.
What People Build With It
Node.js is a good fit for programs that handle many small tasks at once — lots of network connections, lots of messages. Common uses include:
- Web servers and APIs (the part of an app that answers requests)
- Real-time features like chat and live updates
- Command-line tools and build tools for web development
- Small automation scripts that glue services together
It is less suited to heavy number-crunching, where other languages have the edge. For most everyday server and tool work, though, it's a strong, fast choice.
Coming Up
Node.js is free and easy to install. In the next chapters you'll set it up on your machine, run your first script, and see this runtime in action.
Exercise
If JavaScript is a language and Node.js is a runtime, what exactly does the runtime add?
Show answer
The runtime is the program that executes the language and provides the surroundings: the V8 engine to run the code, plus access to the computer's files, network, and memory. In the browser, the runtime adds web page tools instead. The language stays the same; the capabilities around it change.
Exercise
Name two things Node.js can do that browser JavaScript cannot.
Show answer
Read and write files on the computer, and open a network server that accepts connections. Node.js is not locked inside the browser's security sandbox.
Spotted a mistake, or code that does not work?