Understand why JavaScript became useful outside the browser.
Why does Node.js exist?
Node.js lets JavaScript run outside the browser. That means JavaScript can build servers, APIs, command-line tools, automation scripts, file processors, and backend applications.
Before Node, most JavaScript ran inside web browsers.
That made JavaScript useful for buttons, forms, menus, page behavior, and browser interaction.
Node changed the location where JavaScript could run.
With Node, JavaScript can run on your computer or on a server without needing a browser.
That is why Node matters: the same language can now be used for browser work and server work.
A first Node program
// file: hello-node.js
const course = "Jit-Node";
const message = "JavaScript is running outside the browser.";
console.log(course);
console.log(message);
hello-node.js is a JavaScript file that can run with Node.
const course stores a value that should not be reassigned.
console.log() prints output in the terminal.
The browser is not involved in this program.
Run it with node hello-node.js.
Server-side JavaScript
Node lets JavaScript run on servers and local machines.
One language
Teams can use JavaScript in both the browser and backend.
Tools
Node powers many build tools, scripts, package managers, and development workflows.
APIs
Node is commonly used to create APIs that browsers and apps can call.
Browser-only thinking
// This only makes sense in a browser page.
document.querySelector("h1").textContent = "Hello";
Node thinking
// This runs in the terminal with Node.
console.log("Hello from Node");
Ask ChatGPT: "Does this JavaScript code need a browser, or can it run in Node?" Then identify every browser-only feature.
Create a file called hello-node.js.
Add two const variables.
Print both values with console.log().
Run the file with node hello-node.js.
Explain why this code does not need the browser.
Thinking all JavaScript must run in the browser.
Trying to use document in a plain Node script.
Forgetting to run Node from the terminal.
Confusing Node with a framework like Express.
Ignoring the difference between browser APIs and Node APIs.
Explain why Node exists, run JavaScript outside the browser, and identify whether JavaScript code depends on browser features.