JavaScript is a language; a runtime supplies the environment in which it executes. A browser supplies documents, buttons and network APIs. Node.js supplies files, processes and other server-side facilities. Both execute JavaScript, but a program using document cannot run unchanged in Node. This distinction explains many beginner errors better than installing another library.
This course starts with command-line examples, then introduces browser interaction and TypeScript. You need a text editor, a terminal and basic familiarity with files. Later browser lessons include the HTML they require. No framework is needed. Work through the chapters in order: TypeScript describes JavaScript values, so its rules make more sense after you have used those values.
Create a small workspace
Install a maintained Node.js release from the official download page. Use Node 22 or later for these exercises, rather than assuming that every feature works in an older installation. Verify the executable with node --version. Create a folder, then save the following file. The .mjs extension explicitly selects an ECMAScript module, abbreviated ESM.
const learner = "Asha";
const minutes = 25;
console.log(`${learner} will practise for ${minutes} minutes.`);
console.log(typeof minutes);
Run node hello.mjs from that directory. It prints Asha will practise for 25 minutes. and then number. const introduces a binding; the quoted value is a string; and the backtick string inserts expressions between its placeholders. console.log asks the runtime to print a value. A program can run successfully and still print the wrong result, so compare its output with your prediction.
What executes where?
| Facility | Browser | Node |
|---|---|---|
| Arrays, objects, functions and promises | Language features | Language features |
document.querySelector | Finds an element | No document by default |
process.argv | Not a standard browser API | Reads command-line arguments |
| ES modules | Use a module script | Use .mjs or package configuration |
A browser console is useful for short experiments. It is not the same as a saved module: top-level bindings and repeated declarations can behave differently across console sessions. Keep course programs in separate files so that an old variable does not accidentally influence a new example.
JavaScript implementations can parse, interpret and compile code internally. Do not build your mental model around the slogan that the language is "only interpreted." What matters here is that syntax errors prevent execution, while errors such as calling a missing function can occur when that statement runs.
Read errors before editing
If node is not found, fix the installation or command path. If the file is not found, check the current directory and exact filename. If a program reports ReferenceError, identify the missing name and the location at which it is used. Installing a package does not fix a spelling error in a local variable. Avoid copying commands into a terminal without understanding which folder they modify.
Exercise: change the program to print two study sessions and their combined duration. Predict whether "25" + "15" produces 40 before trying it. Explain why the original numeric values behave differently.
Solution guidance: use two numeric bindings and add them inside the template string. The number sum is 40; adding the two strings concatenates them into 2515. The next lesson makes those conversion rules explicit.
Continue reading: MDN JavaScript Guide.

