JavaScript Environment Setup

You do not need to install anything big to start JavaScript. Every browser can already run it. Here are the three easy ways.


1. The browser console (quickest)

  • Open Chrome, Firefox or Edge.
  • Press F12 (or Ctrl + Shift + J, Cmd + Option + J on Mac) and click the Console tab.
  • Type 2 + 3 and press Enter. The console shows 5.

The console is perfect for small tests.


2. An HTML file with a script

Install a code editor like VS Code, create a file named index.html and write:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>My JavaScript Page</title>
</head>
<body>
  <h1>Hello</h1>

  <script>
    console.log("It works!");
  </script>
</body>
</html>

Open the file in the browser, open the Console, and you will see It works!.


3. An external JavaScript file

For real projects keep JavaScript in its own file, and link it before the closing </body> tag, or in the head with defer.

<script src="app.js" defer></script>
// app.js
console.log("Loaded from app.js");

Optional: Node.js

Node.js runs JavaScript outside the browser. Install it from nodejs.org, save code in a file like app.js and run it from the terminal.

node app.js
Note: Install the VS Code extension “Live Server”. It reloads the page every time you save the file.

Summary

  • Use the browser console for quick tests.
  • Use an HTML file with a <script> tag, or an external .js file, for real work.
  • Next: JavaScript Basic Program.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.