Welcome to JavaScript: The Language of the Web

JavaScript was created by Brendan Eich in 1995, originally in just ten days, to make web pages interactive. Three decades later it has grown into one of the most widely used programming languages in the world — it runs in every major browser, and through Node.js it also runs on servers, powering companies like Netflix, […]

Variables, Data Types and Template Literals

JavaScript has three ways to declare a variable, and picking the right one is a habit worth building early — use const by default, and let only when the value genuinely needs to change later. const price = 19.99; // won’t be reassigned let quantity = 3; // will change var oldStyle = “avoid”; // […]

Operators, Conditionals and Truthy Values

Comparison: == vs === 0 == “0” // true (converts types first — avoid this) 0 === “0” // false (strict, checks type too — use this) 1 === 1 // true “a” === “a” // true Always use === and !== in JavaScript, never == and !=. The loose versions perform confusing automatic type […]

Functions and Arrow Functions

function greet(name, greeting = “Hello”) { return `${greeting}, ${name}!`; } const greetArrow = (name, greeting = “Hello”) => `${greeting}, ${name}!`; console.log(greet(“Yash”)); // Hello, Yash! console.log(greetArrow(“Yash”)); // Hello, Yash! Why arrow functions Arrow functions are shorter to write and, importantly, don’t rebind this the way regular functions do — which matters a great deal once you […]

Arrays and Objects

Arrays const courses = [“Python”, “JavaScript”, “SQL”]; courses.push(“Java”); const webCourses = courses.filter(c => c !== “Python”); const upper = courses.map(c => c.toUpperCase()); const hasJava = courses.includes(“Java”); // true map, filter, and reduce are the three array methods you’ll reach for constantly — they transform data without writing manual loops, and none of them modify the […]

The DOM: Selecting and Updating Elements

The DOM (Document Object Model) is how JavaScript sees and changes a web page — every HTML element becomes an object your code can read, modify, or remove entirely. const heading = document.querySelector(“h1”); heading.textContent = “Updated by JavaScript”; heading.style.color = “#00f0ff”; querySelector accepts any CSS selector — a tag name, a class with a dot, […]

Asynchronous JavaScript: Promises and async/await

Some operations — fetching data from a server, reading a file — take time to complete. Unlike a normal function call, JavaScript doesn’t pause and wait for these; it hands you a Promise, an object representing a value that will exist eventually, and moves on to run other code in the meantime. fetch(“https://api.example.com/courses”) .then(response => […]

Modules and What’s Next

Splitting code into modules // math.js export function add(a, b) { return a + b; } // app.js import { add } from “./math.js”; console.log(add(2, 3)); // 5 export makes a function, variable, or class available to other files; import brings it into whichever file needs it. This is how real projects stay organized across […]

Closures and Higher-Order Functions

A closure is a function that remembers the variables from the scope it was created in, even after that outer scope has already finished running. This sounds abstract until you see it solve a real problem. function makeCounter() { let count = 0; return function () { count++; return count; }; } const counter = […]