JavaScript Setup

You can start learning JavaScript with just a web browser. First, open the browser Console and try a few simple commands. Then create a small web page with an HTML file and a JavaScript file. As your projects grow, you can use VS Code and tools such as Live Server or Node.js to write, test, and run your code.

For browser-based JavaScript, a modern browser is enough to get started.

Required to start

A modern browser with Developer Tools and a JavaScript Console.

Recommended

VS Code for writing and organizing HTML and JavaScript files.

Optional

Node.js, Live Server, and Prettier. You can add them later.

A browser already includes a JavaScript engine. Its Developer Tools contain a Console, where you can run JavaScript immediately without installing anything.

  1. Open Developer Tools with F12 or Ctrl + Shift + I. On Mac, use Cmd + Option + I.
  2. Choose the Console tab.
  3. Type the code below and press Enter.

javascript

console.log("Hello JavaScript!");

First success: When you see Hello JavaScript! in the Console, you have run JavaScript. The Console is excellent for quick experiments; VS Code will help when you need files and multiple lines.

After you create index.html and script.js , you can run the page in either of these ways:

  1. Open the file directly: open index.html in your browser, then check Developer Tools and the Console.
  2. Use Live Server: right-click index.html and choose Open with Live Server. This is optional and refreshes the page when you save.

Checkpoint: You are ready to continue when index.html and script.js exist, the page loads, and the Console shows Hello JavaScript.

You can start learning browser JavaScript without Node.js. Node.js is a JavaScript runtime that lets JavaScript run outside the browser, and npm is the package manager commonly used with Node.js. This section is useful when you are ready to run JavaScript from a terminal.

A terminal is a text-based way to interact with your computer. Use it to move into a project folder and run commands such as node and npm. You do not need to memorize every command: copy one command, run it, and compare the result with the example.

  1. Install Node.js (optional): download the current LTS release from nodejs.org and follow the installer instructions.
  2. Create a folder: make a folder named javascript-practice somewhere easy to find.
  3. Open the folder: in VS Code, choose File > Open Folder and select javascript-practice. The folder name should appear in the Explorer panel.
  4. Open the terminal: choose Terminal > New Terminal. The terminal should start inside your project folder.

Terminal check: type the command for your operating system. The version number can be different from the example.

Where to open a terminal on each operating system.
Operating system Standalone terminal Useful beginner note
Windows Windows Terminal, PowerShell, or Command Prompt Use cd to change folders. VS Code's integrated terminal works the same way.
macOS Terminal or iTerm2 Use cd to change folders. The default shell is usually zsh.
Linux Your distribution's Terminal app Use cd to change folders. The exact app name depends on your desktop environment.

terminal

node --version
npm --version

Example terminal result

PS C:\javascript-practice> node --version
v22.14.0
PS C:\javascript-practice> npm --version
10.9.2

If both commands print a version, Node.js and npm are ready. If you see command not found, is not recognized, or a similar message, install the current LTS version of Node.js from nodejs.org, restart the terminal and run the checks again. npm is included with Node.js.

Your first Node program: create a file named hello.js in the Explorer and add this code:

hello.js

console.log("Hello from Node.js");

Save the file, then run it from the terminal:

terminal

node hello.js
Hello from Node.js
Beginner checkpoint: You are ready to continue when VS Code shows hello.js, node --version prints a version, and node hello.js prints the greeting. The browser Console and Node.js are two different places where JavaScript can run.
learning-path

To start learning JavaScript, you only need a modern web browser. You can begin without installing anything by opening the browser's Developer Tools and using the Console. Chrome, Firefox, Edge, and Safari are all good examples.

If you want one example browser, Google Chrome is a common choice because its developer tools are beginner-friendly. Firefox, Edge, and Safari also include developer tools that work well for learning and debugging JavaScript. Download Google Chrome

An IDE (Integrated Development Environment) or code editor gives you one place to write, organize, and debug code. VS Code is a code editor with many IDE-like features, rather than a traditional full IDE.

A code editor can help you with autocomplete, syntax highlighting, and error hints. You can focus on the code rather than repetitive formatting.

Visual Studio Code (VSCode) is a free and lightweight code editor used by beginners and professionals. It is recommended for writing and organizing JavaScript, but it is not required to run JavaScript. You can also practice in the browser Console or use another basic editor.

We will often use VSCode examples in this course because it is beginner-friendly. If you want to use it, download it here: Download VSCode

After installation, create one project folder on your computer. Then in VSCode, go to File > Open Folder and select that folder. This is a simple way to create and manage your first files.

Visual Studio Code download buttons for Windows, macOS, and Linux with links to other builds.

Learn more about Visual Studio Code here .

VS Code extensions add optional features to the editor.

Live Server and Prettier are useful optional extensions. You can install them later.

  • Live Server (optional): Live Server opens your project through a small local development server and refreshes the browser automatically whenever you save changes. It is useful, but you can learn without it.
    live sever
    If you install it, you can launch Live Server by right-clicking inside your HTML file and choosing "Open with Live Server". You can also use Alt + L, Alt + O on Windows/Linux, or Option + L, Option + O on Mac. Learn more about Live Server
  • Prettier (optional): Prettier automatically formats your code so it stays clean and consistent. It handles indentation, spacing, and line breaks for you, which makes your code easier to read and maintain.
    prettier
    Learn how to set up Prettier
learning-path

"Separation of concerns" means organizing code by responsibility. In a small website, separate HTML, CSS, and JavaScript files are one common approach.

HTML defines structure, CSS controls presentation, and JavaScript adds behavior. Organizing these responsibilities separately can make a project easier to read and maintain.

learning-path

Your project can start with two files:

javascript-practice/
|-- index.html
`-- script.js

HTML holds the page structure, and JavaScript holds the behavior. Separate files make each part easier to find and edit.

  1. Step 1: Open VSCode, or any editor you prefer.
  2. Step 2: Create a new folder or open an existing folder for your project.
  3. Step 3: Create HTML File Create a new file and save it as index.html. To follow the separation of concerns principle, keep JavaScript in a separate file and link it with a script tag like <script src="script.js"></script>.
  4. html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>My JavaScript Page</title>
      </head>
      <body>
        <h1>Hello JavaScript</h1>
        <script src="script.js"></script>
      </body>
    </html>
  5. Step 4: Create JavaScript File Create another file named script.js. Add simple JavaScript code there.
  6. javascript

    console.log("Hello JavaScript");
    
  7. Step 5: Run in Browser or Start Live Server Open index.html directly in your browser. Then open Developer Tools and check the Console to confirm your output appears correctly. If you installed Live Server, you can use it instead.
usestrict

"use strict" enables strict mode in a script or function. It changes some language behavior and makes certain mistakes, such as assigning to an undeclared variable, throw errors.

Optional concept for now: Modules are strict by default, so you do not need to add "use strict" in module files. For now, you can learn the syntax without using it.

javascript

// This code works without 'use strict'
x = 10; // It creates a global variable 'x' accidentally.
console.log(x); // Output: 10

javascript

'use strict';
x = 10; // This will throw an error because 'x' isn't declared.
console.log(x); // This line won't be executed due to the error above.

Place "use strict" before other statements at the top of a script, or at the start of a function body. Example:

javascript

//At the beginning of a script:
"use strict";
// Your JavaScript code goes here

//At the beginning of a function:
function myFunction() {
  "use strict";
  // Code for this specific function
}

If it is at the top of the file, strict mode applies to the whole file. If you place it inside a function, it applies only to that function.

Note: We will cover more strict mode rules in a dedicated tutorial.

Every modern browser includes built-in Developer Tools. These tools help you inspect page elements, test JavaScript in the Console, and debug issues quickly.

Open them with F12 or Ctrl+Shift+I (Cmd+Option+I on Mac). You will use the Console tab a lot in this course to view output and error messages.

  • Console: run JavaScript and read logs or errors.
  • Elements: inspect the page's HTML and CSS.
  • Sources: pause and debug JavaScript.
  • Network: inspect requests made by a page.
Note: We will explore these panels step by step in upcoming tutorials.
Chrome DevTools Sources tab with cart.js open in the editor and its file tree on the left.

Minimum setup

  • Modern browser
  • Developer Tools
  • Browser Console

Recommended setup

  • VS Code
  • A javascript-practice folder
  • index.html and script.js

Optional tools

  • Node.js and npm
  • Live Server
  • Prettier

Ready to continue? If the browser Console showed your greeting, you already have enough to keep learning.

  • Web Browser: A modern browser is enough to start learning JavaScript. Open Developer Tools and use the Console.
  • Code editor: VSCode is a recommended code editor for writing and managing files, but JavaScript also runs without it.
  • Node.js and npm: Optional tools for running JavaScript outside the browser and managing packages.
  • Extensions: Live Server is optional for serving a local page, and Prettier is optional for clean formatting.
  • Separation of Concerns: Organize HTML, CSS, and JavaScript by responsibility; separate files are one common approach.
  • "use strict": Strict mode is automatic in modules. The "use strict" directive enables it in classic scripts or functions.
  • Developer Tools: Built into browsers and very helpful for debugging, especially the Console panel.

What's next? Now that your setup is ready, let's explore what makes JavaScript special in the next tutorial.

Set Up for JavaScript, Hindi video
SimplyJavaScript Logo
Setup For Javascript
Set Up for JavaScript, English video
SimplyJavaScript Logo
Setup For Javascript

Reviewed by

SimplyJavaScript Editorial Team

Technical editors and JavaScript educators with hands-on experience building frontend projects, writing learning material, and reviewing tutorials for clarity, accuracy, and beginner-friendly guidance.

c