Skip to main content

JavaScript Guide

About this guide

This is a complete 11-chapter guide that teaches the fundamentals of JavaScript systematically, from variables to browser manipulation and asynchronous processing. Each chapter comes with code examples and beginner-friendly explanations so that even people new to programming can follow along.

Features of this guide
  • From the basics, in order: Starting with variables and data types, you learn in a continuous flow through functions → objects → browser manipulation → asynchronous processing.
  • Code-example focused: Every code block has comments showing the result, so you can follow "what happens" with your eyes.
  • Beginner-friendly explanations: At key points in each chapter, :::tip notes add context and address common stumbling blocks ahead of time.
  • Modern syntax: Covers today's mainstream notation, including arrow functions, destructuring, the spread syntax, async/await, optional chaining (?.), and the nullish coalescing operator (??).

Structure of the guide

Overview of the 11 chapters

ChapterThemeOverview
Variables and constantsContainers for dataThe difference between let / const / var, scope, hoisting, and the TDZ
Data typesKinds of valuesThe 7 primitive types and reference types, typeof, Array.isArray()
ConditionalsBranchingif / the ternary operator / switch, truthy and falsy, the nullish coalescing operator ??
LoopsRepetitionChoosing between for / while / for...of / for...in
FunctionsReusable blocksFunction declarations / function expressions / arrow functions, this, default and rest parameters
ObjectsStructuring dataLiterals, destructuring, the spread syntax, optional chaining ?.
ArraysOrdered collectionsBasic operations and higher-order functions (map / filter / reduce), Array.at()
DOM manipulationDriving HTMLGetting, manipulating, and creating elements; choosing between textContent and innerHTML
Event handlingReacting to user actionsRegistering listeners, event propagation, event delegation
Asynchronous processingWriting code that waitsCallbacks → Promises → async/await, Promise.allSettled
Best practicesToward good codeNaming conventions, structuring, error handling, modules, debugging

How to read this guide

  • If you are learning for the first time: Read in order starting from Variables and constants, and actually write and run the code as you go.
  • If you have already learned the basics: It's fine to jump straight to topics that interest you from the table and read selectively.
  • If you only want browser manipulation: We recommend the flow DOM manipulationEvent handlingAsynchronous processing.
When you try out the code

Each code example is independent per block. When you try them in something like the browser console, run them one block at a time. Some places reuse the same variable name (such as const user) across different blocks, so pasting them all together can cause an Identifier 'x' has already been declared error.

Where this guide fits

This guide focuses on the fundamentals of the JavaScript language itself. Because all of the other structured learning guides on this site assume knowledge of JavaScript, this guide serves as their entry point.

  • TypeScript Guide — Add types to JavaScript to write it safely. The "JS basics" in this guide are a prerequisite.
  • Clean Code — Design standards that raise the quality of the code you can now write.

The intended path is to solidify the fundamentals of JavaScript with this guide, pick up types with the TypeScript Guide, and raise quality with Clean Code.

Helpful resources

These are standard resources for deepening your study.


Now let's get started with Variables and constants.