Learn JavaScript: Complete Roadmap
A structured path for beginners and programmers coming from other languages to master modern JavaScript (ES6+), covering the mental model through async patterns, tooling, and a deployable capstone project.
study, coding, productivity
by Morris
The JavaScript Mental Model
Before writing code, understand what JavaScript actually is and how it runs. Getting this model wrong causes persistent confusion about async, this, and timing behavior.
- Understand the JavaScript runtime: single-threaded execution with an event loop
- Run JavaScript in both environments: browser console (DevTools) and Node.js REPL
- Understand that 'JS is weird' but for specific, learnable reasons
- Understand the distinction between primitive values and objects
- Write your first JS program: a small script that runs in both browser and Node.js
Types, Coercion, and Equality
JavaScript's type system is the source of most beginner confusion and many interview questions. Understanding coercion lets you write safe code and debug surprising behavior.
- Learn the 7 primitive types and their typeof values
- Understand truthy and falsy values - JavaScript's implicit boolean conversion
- ALWAYS use === (strict equality) - understand why == is dangerous
- Understand NaN and why NaN !== NaN
- Understand explicit type conversion and when to use it
Functions and Scope
Functions in JavaScript are more flexible than in most languages. Understanding declarations vs expressions, closures, and hoisting prevents a whole class of subtle bugs.
- Learn the three ways to define functions and the key differences
- Understand hoisting: why function declarations and var are available before their code
- Understand closures: functions that remember their creation scope
- Understand block scope vs function scope - and why var is never used in modern JS
- Understand default parameters, rest parameters, and the spread operator in functions
this Binding
The 'this' keyword is the most confusing part of JavaScript. It works differently from every other language. Understanding the four binding rules eliminates the confusion permanently.
- Understand the fundamental rule: 'this' is determined at CALL TIME, not definition time
- Learn the four 'this' binding rules: default, implicit, explicit, and new
- Learn why arrow functions solve the most common 'this' bugs in callbacks
- Use bind(), call(), and apply() for explicit this control
Arrays and Objects
Arrays and objects are the workhorses of JavaScript. Modern array methods replace manual loops. Destructuring and spread make data manipulation concise and safe.
- Master the functional array methods: map, filter, reduce, find, some, every
- Use flat and flatMap for working with nested arrays
- Master destructuring for arrays and objects
- Use optional chaining (?.) and nullish coalescing (??) to handle missing data safely
- Use Object.keys, Object.values, Object.entries, and Object.assign for object manipulation
The DOM and Events
The DOM is how JavaScript talks to the browser page. Learn these patterns for the real-world web - but note that modern projects usually use React or another framework on top of this.
- Select elements with querySelector and querySelectorAll - forget getElementById
- Add event listeners correctly and understand event bubbling
- Use event delegation to handle events on dynamic or many elements
- Manipulate the DOM: create, update, and remove elements
Async JavaScript
Asynchronous programming is where JavaScript becomes either elegant or a nightmare. Learn the progression from callbacks to Promises to async/await - understanding each layer helps when things go wrong.
- Understand the callback pattern - know it, but don't write new code with it
- Master Promises: then, catch, finally, Promise.all, and Promise.race
- Use async/await as the standard way to write asynchronous code
- Use the Fetch API to make HTTP requests
ES6+ Modern Syntax
Modern JavaScript (ES6 and later) added features that transformed the language. These patterns appear in all professional JS code.
- Use const and let exclusively - var should never appear in modern code
- Use template literals for all string interpolation and multi-line strings
- Understand ES6 classes - syntactic sugar over prototypes
- Use ES Modules (import/export) for code organization
- Use Map and Set when objects and arrays don't fit
Modules and Tooling
Understanding npm, package.json, and modern bundlers is essential for working in any JS project. Vite is the current standard for new projects.
- Learn npm fundamentals: init, install, package.json, and node_modules
- Use Vite as your bundler for new projects - not webpack
- Understand the difference between CommonJS and ES Modules - and when each appears
- Set up a .gitignore for JS projects
Error Handling and Debugging
Debugging is a core skill, not an afterthought. Learning browser DevTools deeply multiplies your effectiveness as a JS developer.
- Use try/catch/finally for synchronous and async error handling
- Master browser DevTools: console, sources (breakpoints), and network tab
- Understand common JS error types and what they mean
Testing
Testing JavaScript requires understanding how to mock the browser, DOM, and network. Vitest is the modern choice for Vite projects; Jest is still prevalent in existing codebases.
- Set up Vitest for a Vite project (or Jest for other setups)
- Write tests using describe, it, and expect with common matchers
- Test async code and mock fetch calls
Capstone Project
Build a complete, deployed web application using all the concepts from this roadmap. Real learning happens when you build something from scratch, encounter real problems, and solve them.
- Choose your capstone project and set up the repository
- Implement async data fetching with proper loading and error states
- Implement localStorage persistence for user data
- Use event delegation for all list-based UI interactions
- Write at least 5 tests for your core utility functions
- Deploy to GitHub Pages or Vercel and share the live URL