codegurukool.com · Free coding tutorials & online compiler

Home › JavaScript Tutorial › JavaScript installation

JavaScript installation

Full step-by-step installation for Windows, macOS and Linux.

Step 1: Install a code editor

  1. Open code.visualstudio.com and click the Download button for your system.
  2. Windows: run the installer, accept the agreement and tick Add to PATH and Open with Code. macOS: open the downloaded zip and drag Visual Studio Code into the Applications folder. Linux: run sudo snap install code --classic or install the .deb file.
  3. Open VS Code once to make sure it starts.

Step 2: Try JavaScript in the browser

  1. Open any web page in Chrome or Edge.
  2. Press F12 and click the Console tab.
  3. Type console.log("Hello") and press Enter to see the result.

Step 3: Run JavaScript from a file

  1. Create index.html in a folder and open the folder in VS Code.
  2. Add a <script> tag before </body> and paste the code from the editor below.
  3. Save, double-click the file and look at the page. Errors appear in the Console.

Optional: install Node.js

  1. Download the LTS version from nodejs.org and run the installer with the default options.
  2. Open a new terminal and run node -v to check it.
  3. Run a file with node app.js.

If something goes wrong

Commands in this lesson

console.log

Definition: Prints a value for debugging.

Syntax:

console.log(value);

Example:

console.log("Sum:", 2 + 3);

Example code

<p id="o"></p>
<script>
  document.getElementById("o").textContent = "JavaScript is working";
</script>

Run this code in the online editor

← Variables and typesFunctions →