The JavaScript behind every web page: values, functions, closures, objects, classes, the event loop, promises and the DOM. Every lesson runs a real program line by line and shows its variables, its call stack and its objects.
JavaScript · beginner · 25 lessons · 2 h 43 min · free
What you'll learn
Read JavaScript confidently: values, types, conditions and loops
Understand functions, scope, hoisting and closures by watching them run
Work with arrays, objects, classes, Map and Set, and know when values are shared
See the event loop order timers, promises and async/await
Change a web page and react to clicks with the DOM
Lessons
The Basics
Variables, types, equality, strings, conditions and loops.
Variables: let and const: Store values with let and const, change them, and see what a variable holds before it is given a value.
Values and Types: Numbers, strings, booleans, null and undefined, checked with typeof. Then see what + and * do when a string meets a number.
Equality, Truthy and Falsy: == converts before comparing, === does not. And every value counts as true or false in an if: see which ones are falsy.
if, else and the Ternary: Choose between branches with if / else if / else, and pick a value with condition ? a : b.
Loops: for, while and for…of: Add up an array with a counting for loop, count down with while, and stop a for…of loop early with break.
Functions
Calls and the stack, arrow functions, scope, closures, recursion and callbacks.
Functions and the Call Stack: One function calls another. Watch each call get its own variables, wait for the inner call, and get its value back.
Arrow Functions, Defaults and Rest: Short arrow functions, a default parameter for when an argument is missing, and ...rest to accept any number of arguments.
Scope and Hoisting: Where a variable can be seen: the whole file, one function, or one block. And why var behaves differently from let.
Closures: A function returned from another keeps the variables it was created with. Two counters each keep their own count.
Recursion: factorial calls itself with a smaller number until it reaches 1. Watch the call stack grow four deep, then unwind.
Functions as Values: Callbacks: Pass a function into another function and let it decide when to call it. Use a named function, then an arrow.
Objects and Arrays
Arrays and their methods, objects, destructuring, classes, this, Map and Set.
Arrays and References: Add and remove items, then see that assigning an array copies the reference, not the array. Spread makes a real copy.
map, filter, reduce and find: Transform, choose, total and search an array of orders. Each method calls your arrow once per item.
Objects: Read, change, add and delete properties, give an object a method, and see two names share one object.
Destructuring and Spread: Unpack values from objects and arrays into variables, rename and default them, and build new objects with ...spread.
Classes and Inheritance: Make objects from a class with a constructor and methods, then extend it with a subclass that adds a method.
How this Works: this depends on how a function is called, not where it is written. Lose it by taking the method out of its object, then fix it with bind.
Map and Set: Collect unique words in a Set and count them in a Map.
Asynchronous JavaScript
The event loop, promises, async/await and errors.
The Event Loop: Why does a 0 ms timer print last? Follow the call stack, the promise queue and the timer queue.
Promises: Wrap a timer in a promise, then chain .then calls so each step starts when the previous one finishes.
async and await: Write asynchronous code that reads like normal code. await pauses only its own function; errors arrive in catch.
Changing the Page (the DOM): Find elements with querySelector, create new ones and add them to the page. The Screen panel shows the page change line by line.
Events: Reacting to Clicks: Register a click listener, type a name and click: the browser calls your function, which reads the input and updates the page.
Related courses
Core Java Fundamentals: Learn Java from the ground up: how the JVM runs your code, data types, operators, conditionals, loops, methods, arrays, strings, object-oriented programming and exceptions. Every lesson traces a real program line by line. (44 lessons, 10 h 11 min)
Advanced Java: Collections, Generics and More: The Java you need beyond the basics: lists, stacks, queues, maps and sets, iterators, generics, ordering, equals and hashCode, enums, nested classes, immutability and resources. Every lesson traces a real program line by line. (14 lessons, 1 h 41 min)
Modern Java 8+ Features: Lambdas, functional interfaces, streams, Optional and the date-time API from Java 8, plus var, records and modern switch from later versions. Every lesson traces a real program line by line. (13 lessons, 1 h 35 min)
Java Interview Questions: Classic Java interview programs, traced line by line with the reasoning behind each step. (4 lessons, 1 h 10 min)