Option 1: Browser Console (Instant, No Install)
The fastest way to run JavaScript is already in your browser. Every modern browser ships with a full JavaScript runtime and developer tools.
- Open Google Chrome or Firefox
- Press F12 (Windows/Linux) or Cmd+Option+J (Mac)
- Click the Console tab
- Type
console.log("Hello!")and press Enter
// Type these in the browser console:
console.log("Hello, World!");
console.log(2 + 2);
console.log(typeof "hello");
// Multi-line object inspection
const user = { name: "Alex", age: 28 };
console.log(user);
console.log()- print valuesconsole.error()- print errors (red)console.table()- print arrays/objects as a table- Shift+Enter - new line without running (for multi-line code)
- Arrow Up / Down - navigate command history
Option 2: Install Node.js (Run JS Anywhere)
Node.js lets you run JavaScript files from the terminal - no browser needed. It also comes with npm, which you will need for installing packages.
Install Steps (Windows / Mac / Linux)
- Go to nodejs.org and download the LTS version (Node 20+)
- Run the installer and follow the prompts (default settings are fine)
- Open a terminal and verify the install:
node --version # should print v20.x.x or higher
npm --version # should print 10.x.x or higher
If you work on multiple projects needing different Node versions, install nvm (Node Version Manager) instead of installing Node directly. It lets you switch between versions: nvm install 20, nvm use 20.
VS Code Setup for JavaScript
Visual Studio Code is the industry-standard editor for JavaScript development. It is free, fast, and has excellent built-in JavaScript support.
Install VS Code
- Download from code.visualstudio.com and install
- Open VS Code and install these extensions:
| Extension | Purpose |
|---|---|
| ESLint | Catches code errors and style issues as you type |
| Prettier | Auto-formats code on save (consistent style) |
| GitLens | Enhanced Git integration |
| Path Intellisense | Autocomplete file paths in import statements |
| Live Server | Auto-reload browser when you save HTML/JS files |
Configure Auto-format on Save
Open VS Code settings (Ctrl+,) and add these to settings.json:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"javascript.preferences.quoteStyle": "single"
}
Run Your First JS File
Create a file called hello.js and run it with Node.js:
const name = "RubanLearn";
const year = new Date().getFullYear();
console.log(`Welcome to ${name}!`);
console.log(`Learning JavaScript in ${year}.`);
// Simple function
function greet(person) {
return `Hello, ${person}!`;
}
console.log(greet("Developer"));
node hello.js
package.json Basics
Every Node.js project has a package.json file that tracks the project name,
version, and dependencies. Create one with:
mkdir my-project && cd my-project
npm init -y # creates package.json with defaults
npm install lodash # install a package (example)
Online Editors (No Install)
For quick experiments without any local setup:
- CodePen - best for HTML/CSS/JS experiments with live preview
- JSFiddle - classic JS sandbox, easy to share
- StackBlitz - full VS Code in the browser, supports Node.js projects
- Replit - full development environment, supports Node.js
- PlayCode.io - fast JS playground with instant output
For following along with this tutorial: use the browser console for the first few lessons (variables, data types, operators), then switch to VS Code + Node.js when you reach DOM and async topics.