









Setting Up JavaScript Environment
Browser Console, Node.js, VS Code
Introduction
Before writing your first line of JavaScript, you need to create the right environment. Think of it like a well-equipped kitchen before you start cooking. This guide will walk you through setting up a JavaScript environment using the browser console, Node.js, and Visual Studio Code (VS Code).
1. Using Browser Console
Every modern web browser (Chrome, Firefox, Safari, Edge) has a built-in JavaScript engine. The browser console is the simplest and fastest way to run small snippets of JavaScript.
How to Open the Console
- Chrome: Right-click on a webpage → Inspect → Console tab
- Firefox: Right-click → Inspect Element → Console
- Edge: F12 or Right-click → Inspect → Console
Example Code
console.log("Hello from the browser!");
Expected Output
Hello from the browser!
Why use it? It's instant. Great for testing small pieces of code or debugging.
2. Setting Up Node.js
Node.js lets you run JavaScript outside the browser — on your computer, like any other programming language. It's essential for building backend services, running development tools, and testing JavaScript apps.
Installation Steps
- Visit nodejs.org
- Download the LTS (Long Term Support) version suitable for your OS
- Run the installer and follow the prompts
Verify Installation
node -v
npm -v
What You Should See
v20.x.x (or your installed Node version)
10.x.x (npm version)
Running JavaScript in Node.js
// Save this as hello.js
console.log("Hello from Node.js");
Run it in Terminal
node hello.js
Expected Output
Hello from Node.js
Pro Tip: You can use node
alone to enter a REPL (interactive shell) for quick tests.
3. Setting Up VS Code
Visual Studio Code is a powerful, lightweight editor with great support for JavaScript. It’s the preferred choice for most developers.
Download & Install
- Go to code.visualstudio.com
- Download the appropriate version for your OS
- Follow the installation steps
Create Your First Project
- Open VS Code
- Create a folder, e.g.,
js-learning
- Open this folder in VS Code (File → Open Folder)
- Create a file
app.js
- Add your JavaScript code
// app.js
let name = "VS Code";
console.log("Running JavaScript in " + name);
Run from Terminal
node app.js
Expected Output
Running JavaScript in VS Code
Optional but Helpful Extensions
- ESLint: Helps catch errors and follow best practices
- Prettier: Auto-formats your code
- Live Server: Instantly reloads your browser when you save HTML/JS
Comparing the Environments
Environment | Best For | Pros | Cons |
---|---|---|---|
Browser Console | Quick experiments, DOM testing | No setup, instant access | Not suited for full apps |
Node.js | Backend, tools, scripts | Runs JS anywhere, access to npm | No DOM access |
VS Code | Full development | Powerful editor, extensions | Requires Node for execution |
Conclusion
You now have three solid ways to start writing JavaScript — each serving a unique purpose. Start with the browser for instant feedback, use Node.js for backend or tool development, and adopt VS Code for full-fledged projects. With this setup, you’re ready to dive deeper into the JavaScript universe with confidence.