Set Up Your JavaScript Environment with VS Code and Browser Developer Tools
Quick Answer: You can write JavaScript using Visual Studio Code and run it directly in a browser. VS Code helps you create and manage your files. Browser Developer Tools help you inspect, debug and test your code. You do not need Node.js for basic browser-based JavaScript development.
1. What Do You Need to Start JavaScript Development?
Imagine you are building a student registration page for a school. You need a place to write the page. You also need a way to run JavaScript and check its behaviour.
You can start with three tools:
- Visual Studio Code: A code editor used to write and manage files.
- Web browser: An application that opens your HTML page and runs browser JavaScript.
- Browser Developer Tools: Built-in tools used to inspect pages and find code problems.
These tools work together, but they have different responsibilities.
Animation 1: From writing code to checking the result
The highlighted stages show the normal development path. The labels remain static and readable while the focus moves automatically.
Do You Need Node.js?
No. You do not need Node.js to run JavaScript inside a browser.
Browsers already include a JavaScript engine. It runs scripts loaded by web pages.
Node.js is a JavaScript runtime used outside the browser. It helps run server-side applications, build tools and command-line programs.
| Browser JavaScript | Node.js |
|---|---|
| Runs inside a web browser. | Runs outside the browser. |
| Can access the page through the DOM. | Can access server-side APIs and the file system. |
| Used for web page behaviour. | Used for servers, scripts and development tools. |
| No separate runtime installation is needed. | Node.js must be installed to run Node programs. |
2. Install Visual Studio Code
Visual Studio Code is commonly called VS Code. It is a free code editor from Microsoft.
Download it from the official website:
- Open the official website.
Choose the download that matches your operating system. - Run the installer.
Follow the installation steps shown on your screen. - Start VS Code.
You should see the editor window and its welcome screen. - Open a project folder.
Choose File, then Open Folder, and select your working folder.
Useful VS Code Features
- Explorer: Shows your project files and folders.
- Editor: Lets you write and change source code.
- Terminal: Runs commands inside the editor.
- Extensions: Adds extra editor features.
- Search: Finds text across your project files.
Recommended Extensions
Start with the built-in JavaScript support. Add extensions only when they help your workflow.
- Live Server: Starts a local development server and refreshes pages when files change.
- Prettier: Formats code using consistent rules.
- ESLint: Reports code patterns that may cause problems.
Important: Extensions are optional. You can build and run the first example without installing them. Install extensions only after checking their publisher and permissions.
3. Create Your First JavaScript Project
We will create a small school registration page. It will show a student's name and registration status.
First, create a folder named school-registration. Open that folder in VS Code.
Create these three files inside it:
Project folder structure
school-registration/
|
|-- index.html
|-- style.css
|-- script.js
Each file has one clear responsibility:
index.htmlcontains the page structure.style.csscontrols the page appearance.script.jscontains the JavaScript behaviour.
Step 1: Add the HTML Page
HTML = the structure of a web page. Add the following content to index.html.
Example 1: index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>School Registration</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main>
<h1>School Registration</h1>
<p id="student-name">Student: Priya</p>
<p id="registration-status">Waiting for registration</p>
<button id="register-button">Register Student</button>
</main>
<script src="script.js"></script>
</body>
</html>
Step 2: Add Basic Styling
CSS = rules that control how page elements look. Add this code to style.css.
Example 2: style.css
body {
font-family: Arial, sans-serif;
background: #f1f5f9;
margin: 0;
padding: 40px 16px;
}
main {
max-width: 480px;
margin: 0 auto;
padding: 28px;
background: #ffffff;
border-radius: 12px;
color: #172033;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
}
h1 {
color: #3730a3;
}
button {
padding: 10px 16px;
border: 0;
border-radius: 6px;
background: #4338ca;
color: #ffffff;
cursor: pointer;
}
button:hover {
background: #312e81;
}
Step 3: Add JavaScript Behaviour
JavaScript = the programming language that adds behaviour to web pages.
We will update the registration status when the user selects the button.
Example 3: script.js
const registerButton = document.getElementById("register-button");
const statusMessage = document.getElementById("registration-status");
registerButton.addEventListener("click", function () {
statusMessage.textContent = "Priya is registered successfully.";
console.log("Registration completed for Priya.");
});
Save all three files. Your project is now ready to run.
4. Run JavaScript in Your Browser
You have two simple ways to open the project.
Option A: Open the HTML File Directly
- Open your project folder in File Explorer.
- Find the
index.htmlfile. - Double-click the file.
- Your default browser should open the page.
This method is enough for this simple example. Some browser features behave differently when pages use local files.
Option B: Use the Live Server Extension
- Open the Extensions view in VS Code.
- Search for Live Server.
- Check the publisher before installing it.
- Install the extension and open
index.html. - Use the extension's Go Live command.
- Your browser should open a local address.
A local development server serves your files through a local web address. It can also refresh the page after file changes.
Remember: Live Server is a development convenience. It is not a production hosting service. Do not expose private project files through an untrusted server.
Test the Registration Page
- Open the page in your browser.
- Check that the student name appears.
- Select the Register Student button.
- Check that the status message changes.
Expected page behaviour
Before clicking: Student: Priya Waiting for registration After clicking: Student: Priya Priya is registered successfully.
5. Open Browser Developer Tools
Developer Tools = built-in browser tools for inspecting and debugging web pages.
They help you understand what happens when JavaScript runs. You can inspect page elements, view messages and pause code execution.
Common ways to open Developer Tools:
| Browser | Windows and Linux | macOS |
|---|---|---|
| Google Chrome | F12 or Ctrl + Shift + I | Command + Option + I |
| Microsoft Edge | F12 or Ctrl + Shift + I | Command + Option + I |
| Mozilla Firefox | F12 or Ctrl + Shift + I | Command + Option + I |
You can also right-click a page and choose Inspect. The exact menu wording may differ by browser.
Important Developer Tools Tabs
6. Use the Console to Run JavaScript
The Console is one of the first tools to learn. It shows messages from your JavaScript code.
Open the Console tab. Type the following expression and press Enter.
Example 4: Run JavaScript in the browser Console
const schoolName = "Green Valley School";
console.log("Welcome to " + schoolName);
Expected output
Welcome to Green Valley School
You can also inspect values and test small expressions.
Example 5: Check values in the Console
const studentName = "Priya";
const marks = 85;
console.log(studentName);
console.log(marks);
console.log(marks >= 40);
Expected output
Priya 85 true
Important: Variables created directly in the Console are useful for quick tests. They do not automatically become part of your saved JavaScript file.
7. Debug JavaScript with Breakpoints
Logging values is useful, but it cannot explain every problem. A breakpoint pauses JavaScript at a chosen line.
Breakpoint = a marker that pauses code execution during debugging.
We will debug the registration page. Open script.js in the Sources tab.
Find the line that updates the registration status. Select its line number to add a breakpoint.
Now return to the page and click Register Student.
Animation 2: Follow a registration click through the debugger
This animation follows the click event into the paused debugger. It highlights the debugging order without moving or blurring text.
Understand the Debugger Controls
- Resume: Continue running until the next breakpoint.
- Step Over: Run the current line without entering another function.
- Step Into: Enter a function called by the current line.
- Step Out: Finish the current function and return to its caller.
- Restart: Restart the current debugging session when supported.
While paused, inspect the variables in the Scope panel. You can also hover over a variable in the source code.
Inspect the Registration Values
At the breakpoint, check the values used by the current callback.
These labels explain the expected values. The actual debugger displays runtime objects and values.
Choose Resume to finish the callback. The browser should update the status message.
8. Inspect HTML and CSS with the Elements Tab
The Elements tab shows the current page structure. It also lets you test style changes.
- Open the Elements tab.
- Find the paragraph with the
registration-statusID. - Select that paragraph.
- Review its HTML and applied CSS rules.
- Try changing a style in the Styles panel.
For example, add this temporary CSS declaration in the Styles panel:
Example 6: Temporary style change
color: #15803d;
font-weight: bold;
The selected text should become green and bold. This change is temporary.
To keep a style change, copy it into your project's style.css file.
9. Inspect Network Requests
The Network tab shows requests made by the page. It helps find missing files and failed API calls.
Try this basic check:
- Open the Network tab.
- Reload your registration page.
- Look for
index.html,style.cssandscript.js. - Check their status and request details.
- Select a request to inspect its headers and response.
A successful local file request normally appears with a successful status. Exact status details depend on how the page is served.
Common issue: If script.js is missing, check the script path in HTML. Also check the browser Console for loading errors.
10. Understand the Complete Development Workflow
These tools are most useful when you use them together. The editor is where you change files. The browser is where you test the result. Developer Tools help explain unexpected behaviour.
| Task | Tool | What to do |
|---|---|---|
| Write JavaScript | VS Code | Edit and save the source file. |
| Organise project files | VS Code Explorer | Create folders and manage files. |
| Run the page | Browser | Open the local page or server address. |
| Check output | Console | Read logs and runtime errors. |
| Inspect page structure | Elements | Review HTML and applied styles. |
| Debug code | Sources | Set breakpoints and inspect values. |
| Check requests | Network | Review file and API requests. |
11. Common Setup Problems and Their Fixes
Problem 1: JavaScript Is Not Running
Possible reason: The script path is incorrect, or the file was not saved.
Check: Confirm the file name and script reference.
Correct script reference
<script src="script.js"></script>
If the JavaScript file is inside a folder named js, use js/script.js.
Problem 2: Button Click Does Nothing
Possible reason: The element ID in JavaScript does not match HTML.
Check: Compare the ID in both files. IDs are case-sensitive.
Problem 3: Console Shows an Error
Possible reason: The code has a syntax error or uses a missing value.
Check: Read the complete error message. Select its source link to inspect the line.
Problem 4: CSS Changes Do Not Appear
Possible reason: The stylesheet path is wrong, or the browser has an older cached copy.
Check: Confirm the link path. Reload the page and inspect the Network tab.
Problem 5: Live Server Does Not Start
Possible reason: The extension is missing, disabled or unable to start.
Check: Confirm the extension is installed. Open the project folder and try its Go Live command again.
12. Best Practices for a Clean JavaScript Setup
- Keep HTML, CSS and JavaScript in separate files.
- Use clear names for folders, files and variables.
- Save your files before testing changes.
- Use the Console to understand errors.
- Use breakpoints when logs are not enough.
- Check the Network tab when files fail to load.
- Do not install extensions without checking their publisher.
- Keep passwords, API keys and private data out of public source files.
- Use a local development server when your project needs HTTP behaviour.
- Learn browser JavaScript before adding build tools and frameworks.
13. Interview Questions and Answers
Q1. What is Visual Studio Code?
What the interviewer expects: Explain its role as a development editor.
Strong answer: "VS Code is a source code editor. I use it to create files, write JavaScript and manage projects. It also supports extensions, debugging and an integrated terminal."
Q2. Can JavaScript run without Node.js?
What the interviewer expects: Understand browser JavaScript and Node.js.
Strong answer: "Yes. Browsers include a JavaScript engine. I can write a script and load it from an HTML page. Node.js is needed when I want to run JavaScript outside the browser."
Q3. What are Browser Developer Tools?
What the interviewer expects: Explain how developers inspect and debug applications.
Strong answer: "Developer Tools are built into modern browsers. I use the Console for messages, Elements for page inspection, Sources for debugging and Network for request analysis."
Q4. What is a breakpoint?
What the interviewer expects: Explain a practical debugging step.
Strong answer: "A breakpoint pauses JavaScript at a selected line. I can inspect variable values and follow the execution. This helps me find where unexpected behaviour starts."
Q5. What is the difference between Console and Sources?
Strong answer: "The Console displays messages and lets me run expressions. Sources helps me inspect files and debug execution with breakpoints."
What Senior Developers Should Also Know
- Use source maps to debug bundled code when available.
- Understand browser caching and hard reload behaviour.
- Use Network throttling to test slower connections.
- Use performance recordings to investigate slow page interactions.
- Understand the difference between local development and production builds.
14. Hands-On Practice
Beginner Exercise: Change the Student Name
Change Priya to Arjun in the HTML and JavaScript files. Run the page again. Confirm that both places show the same name.
Expected result: The page and registration message should show Arjun.
Intermediate Exercise: Add a Marks Display
Add a marks paragraph to the page. Use JavaScript to show a student's marks after clicking a button.
Hint: Use getElementById and textContent.
Advanced Exercise: Debug a Missing Element
Change the JavaScript element ID so it no longer matches HTML. Reload the page and inspect the Console.
Find the failing line. Fix the ID and test the page again.
Practice Checklist
- Can you create a project folder in VS Code?
- Can you connect HTML, CSS and JavaScript files?
- Can you open the page in a browser?
- Can you run JavaScript from the Console?
- Can you inspect an HTML element?
- Can you set a breakpoint and inspect a variable?
- Can you identify a missing file in the Network tab?
15. Official Documentation and Next Steps
Use official documentation when you need details about tools and browser behaviour.
- Visual Studio Code Documentation – Learn the editor, extensions and debugging features.
- Chrome DevTools Documentation – Learn browser inspection and debugging.
- MDN JavaScript Guide – Learn JavaScript language features.
- MDN Learn Web Development – Learn HTML, CSS and browser development.
- Node.js Downloads – Install Node.js when you begin server-side JavaScript or Node-based tooling.
Share Your Knowledge
Try the registration project and explore each Developer Tools tab. Share your setup tips and debugging discoveries with other learners. Discuss different workflows and help beginners solve setup problems.
You are ready to write, run and debug your first JavaScript project.
Upgradix by Shrash Studio
Learn Technology. Build Your Future.
Quality Technology Education. Completely Free.