JavaScript Get Started

</>Coding Tamilan.← JavaScript course

JavaScript · Lesson 02 / 32 · English

JavaScript Get Started

Understand the idea. Change the code. Build confidence with one focused experiment.

Detailed notesRunnable JavaScriptPractice + answer

Read this lesson in தமிழ் ↗.

01 / Understand

Start with the idea

You can begin in a browser console or the editor below. Run a small script first, then move it into a project file. Browser page scripts can use a deferred external script so the HTML is parsed before the script runs.

Learning goal: Explain what the example does, predict its result, and change it to solve the practice task.

02 / Explore

Step-by-step lesson notes

Running JavaScript

JavaScript runs anywhere — in the browser, on the server with Node.js, or even inside desktop apps. You don't need to install anything to get started.

1. The Browser Console

The fastest way to try JavaScript is your browser's built-in console.

  1. Open any browser (Chrome, Firefox, Edge)
  2. Press F12 (or right-click → Inspect)
  3. Click the Console tab
  4. Type JavaScript and press Enter
JavaScript reference fragmentCODE
// Try typing this in your browser console:
console.log("Hello, World!");
2 + 2
[1,2,3].map(x => x * 2)

2. JavaScript in HTML

Add JavaScript to any HTML page with a <script> tag.

JavaScript reference fragmentCODE
<!DOCTYPE html>
<html>
<head>
  <title>My Page</title>
</head>
<body>
  <h1 id="title">Hello</h1>

  <!-- Always put script just before </body> -->
  <script src="script.js"></script>
</body>
</html>
JavaScript reference fragmentCODE
// script.js
document.getElementById("title").textContent = "Hello from JavaScript!";

3. Node.js (Server-side)

Node.js lets you run JavaScript outside the browser — on your computer or a server.

  1. Download Node.js from nodejs.org
  2. Create a file: hello.js
  3. Run it: node hello.js
JavaScript reference fragmentCODE
// hello.js
console.log("Hello from Node.js!");
console.log("Node version:", process.version);
EnvironmentHow to runUse case
Browser ConsoleF12 → Console tabQuick experiments
HTML + Script tagOpen .html in browserWeb pages
Node.jsnode filename.jsServer, scripts, CLIs
Online editorscodepen.io, jsfiddle.netSharing & demos
03 / Read & predict

A complete example

Run this complete index.js program in the JavaScript console editor below. The earlier reference fragments may need a browser page or other surrounding setup.

index.js · complete exampleCODE
console.log("My first JavaScript session");
console.log(12 + 8);
Predict first. Reveal the expected result.
My first JavaScript session
20
04 / Experiment

Make one change. See what happens.

Load the example, change a value, predict the output, and run it again. Use the console output to check your reasoning.

Open editor ↗

Wait for the editor to load, then load this example and press Run.

Powered by the free OneCompiler editor. Code you run is sent to that external service. Keep personal data and secret keys out of your examples.

05 / Your turn

Put the idea to work

Practice challenge

Print your name on one line and 7 multiplied by 6 on the next.

Reveal the answer and reasoning

Use console.log("Your name"); followed by console.log(7 * 6);. The second line is 42.

One mistake to avoid: Do not include the Console prompt symbol > when copying a command. Browser DOM APIs are not available in every JavaScript runtime.

Your learning checkpoint

  • Explain the example in your own words.
  • Complete the challenge before revealing its answer.
  • Describe the common mistake and how to avoid it.
Coding Tamilan · Learn by doing.