JavaScript Introduction

</>Coding Tamilan.← JavaScript course

JavaScript · Lesson 01 / 32 · English

JavaScript Introduction

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

JavaScript connects values, calculations, and actions. Start with a named value and a console message.

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

What is JavaScript?

JavaScript is the programming language of the Web. It is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions.

JavaScript is used for:

  • Making web pages interactive and dynamic
  • Building web applications (front-end and back-end with Node.js)
  • Mobile app development (React Native, Ionic)
  • Desktop applications (Electron)
  • Game development
  • Server-side programming

Why Learn JavaScript?

  • It is the primary scripting language used for browser page behaviour
  • It is one of the most popular languages in the world
  • Huge job market demand
  • Versatile — works on frontend, backend, mobile, and desktop
  • Large ecosystem with npm (1M+ packages)
  • Active community and constant evolution (ES6, ES7, ES2023+)

How JavaScript Works

JavaScript runs directly in the browser's JavaScript engine (like V8 in Chrome or SpiderMonkey in Firefox). There is no compilation step needed — you write the code and the browser runs it.

EngineBrowser / PlatformNotes
V8Chrome, Edge, Node.jsPowers Chromium-based browsers and Node.js
SpiderMonkeyFirefoxFirst-ever JavaScript engine
JavaScriptCoreSafariAlso called Nitro
ChakraLegacy EdgeReplaced by V8 in modern Edge

Your First JavaScript Program

JavaScript reference fragmentCODE
// Output to the browser console
console.log("Hello, World!");

// Show a popup
alert("Welcome to JavaScript!");

// Write to the page
document.write("<h1>Hello from JS!</h1>");

Tip: Open your browser's developer tools (press F12) and go to the Console tab to run JavaScript live.

Where Does JavaScript Go?

JavaScript can be placed inside HTML in three ways:

JavaScript reference fragmentCODE
<!-- 1. Inline (inside an element) -->
<button onclick="alert('Clicked!')">Click Me</button>

<!-- 2. Internal (inside a script tag) -->
<script>
  console.log("Internal script");
</script>

<!-- 3. External (best practice) -->
<script src="script.js"></script>

Best Practice: External scripts are useful for maintainable projects. A classic external script can use defer in the document head, or be placed after the elements it uses.

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
const learner = "Coding Tamilan";
const lessons = 3;
console.log("Hello, " + learner + "!");
console.log("This week: " + lessons + " lessons");
Predict first. Reveal the expected result.
Hello, Coding Tamilan!
This week: 3 lessons
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

Change lessons to 5 and predict the second line.

Reveal the answer and reasoning

This week: 5 lessons. The text stays the same; the number changes.

One mistake to avoid: Java and JavaScript are separate languages. console.log writes to the console, not the webpage.

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.