JavaScript Lesson 1: What is JavaScript?
JavaScript is the programming language of the web. Every button you click, every form you fill, every animation you see — JavaScript makes it happen. It runs directly in your browser, no installation needed.
The Three Languages of the Web
HTML — Structure (the bones)
CSS — Style (the skin)
JS — Behavior (the muscles)
<!-- HTML -->
<button id="myBtn">Click me</button>
/* CSS */
button { background: purple; color: white; }
// JavaScript
document.getElementById("myBtn").onclick = function() {
alert("You clicked me!");
};
Where JavaScript Runs
// 1. In the browser — runs on the user's computer
// Open DevTools (F12) → Console → type JS here!
console.log("Hello from the browser!");
alert("I am a popup!");
// 2. In Node.js — runs on a server (Lesson 20+)
// node my-file.js
// For now: everything runs in the browser
Your First JavaScript
// In an HTML file:
<!DOCTYPE html>
<html>
<head><title>My JS</title></head>
<body>
<h1 id="title">Hello!</h1>
<script>
// JS goes here, or in a separate .js file
console.log("JavaScript is running!");
document.getElementById("title").textContent = "Changed by JS!";
</script>
</body>
</html>
Why Learn JavaScript?
- Only language that runs natively in every browser
- Used by 98% of all websites
- Same language for frontend AND backend (Node.js)
- Massive ecosystem (npm has 2 million packages)
- React, Vue, Angular — all built on JavaScript
🏋️ Practice Task
Open your browser DevTools (press F12). Go to the Console tab. Type: console.log(“My name is [your name]!”) and press Enter. Then type: 2 + 2 and see the result. You just ran JavaScript!
💡 Hint: F12 opens DevTools in Chrome, Firefox, and Edge. The Console is a live JavaScript environment.