← JavaScript

JavaScript study guide

A reference for interviews, not a tutorial. 50 topics from the basics up, each one explaining the mechanism with runnable examples and ending with questions from the same bank the quizzes draw from.

50 of 50 written · 214 quiz questions

Basic

12 of 12 written · 60 quiz questions →

Types, coercion, operators and the array and object basics that every screening call starts with.

  1. Primitive values12 minThe seven primitive types, what immutability actually means for them, and why copying a primitive behaves differently from copying an object.PrimitivesNumbers
  2. Operators15 minWhat each operator returns rather than what it tests, why `||` and `??` are not interchangeable, and the precedence rules that actually catch people.Operators
  3. Functions15 minDeclarations, expressions and arrows, what first-class really buys you, and the parameter features worth knowing by heart.Functions
  4. Scope and the scope chain16 minWhere a name is visible, how the engine looks one up, and why `let` in a loop behaves differently from `var`.Scope
  5. if, truthy and falsy14 minThe eight falsy values, why an empty array is not one of them, and the operators that let you stop writing if at all.Control flow
  6. for, for...in and for...of13 minThree loops that look alike and iterate different things, plus which ones you can break out of and why that matters.Control flow
  7. while13 minThe loop for when you do not know how many iterations there are, and how to keep it from running forever.Control flow
  8. do...while11 minThe one loop that always runs at least once, where that is exactly what you want, and the snippet interviewers use to test it.Control flow
  9. Type coercion12 minWhy `+` behaves differently from every other operator, what `==` does before it compares, and the handful of conversions worth memorising.Type coercionEquality
  10. Arrays16 minWhat each array method gives back, which ones change the array underneath you, and the handful that behave differently from how their names read.Arrays
  11. Objects: the basics17 minHow property keys really work, the difference between dot and bracket access, and the three ways to ask whether a property is there.Objects
  12. String and array handling14 minThe string methods worth knowing by heart, how to cross between strings and arrays, and the small exercises interviewers use to test both.Strings

Intermediate

17 of 17 written · 82 quiz questions →

Hoisting, closures, `this`, array transforms and modules — where most interviews actually spend their time.

  1. Strict mode14 minWhat `"use strict"` actually changes, why every module is already strict, and the handful of silent failures it turns into errors.Strict mode
  2. Hoisting16 minWhat the engine does before your first line runs, why `var` gives `undefined` and `let` throws, and how to read any hoisting snippet.Hoisting
  3. The Temporal Dead Zone12 minThe window where a `let` or `const` exists but cannot be touched, why `typeof` throws in it, and the three snippets that test it.Temporal Dead Zone
  4. Closures9 minWhy a function remembers the variables around it, and the three places that memory surprises people.Closures
  5. this in objects18 minThe four rules that decide what `this` is, why a detached method loses it, and what arrow functions actually do differently.this
  6. call, apply and bind15 minThe three ways to say what `this` should be, which one calls immediately, and the borrowing and partial-application tricks they enable.call / apply / bind
  7. Classes17 minWhat `class` is syntax for, where the methods actually live, and the fields, getters, statics and private names worth knowing.Classes
  8. Callbacks16 minA function passed to be called later, the error-first convention, and why callback hell and lost context led to promises.Callbacks
  9. Higher-order functions17 minFunctions that take or return functions, the array methods built on them, and the composition, currying and memoising patterns they make possible.Higher-order functions
  10. Destructuring15 minPulling values out of arrays and objects by shape, with defaults, renaming and nesting — and the three syntax traps.Destructuring
  11. Spread and rest15 minThe same three dots doing two opposite jobs, where each one is legal, and why the copy they make is only one level deep.Spread & rest
  12. Set, Map, WeakMap and WeakSet17 minThe four keyed collections, what each one does that an object or array cannot, and when the weak versions are the right answer.Set, Map & friends
  13. ES modules15 minNamed and default exports, why imports are live bindings rather than copies, and what static analysis buys you.Modules
  14. CommonJS and require15 minNode's original module system, why `require` returns a cached copy, and the differences from ES modules that actually bite.Modules
  15. Recursion19 minThe base case and the recursive case, how to read a call trace, and the depth limit that decides when a loop is the safer choice.Recursion
  16. Flattening nested arrays13 minWhat `flat` does and does not do by default, the recursive and reduce versions interviewers ask for, and `flatMap` as the one-level shortcut.Arrays
  17. Recursive sum and range15 minTwo exercises that come up constantly, written four ways each, with the accumulator pattern that generalises to the rest.Recursion

Advanced

11 of 11 written · 72 quiz questions →

The event loop, promise combinators, prototypes and proxies — the questions senior interviews end on.

  1. The call stack15 minHow the engine tracks what is running, what a stack trace is really telling you, and why it overflows.Call stack
  2. The event loop9 minHow one thread runs everything, why promise callbacks always beat timers, and how to read any "what order does this log?" question off the rules.Event loopCall stack
  3. Promises23 minThe three states, what `then` really returns, the four combinators, and how `async`/`await` maps onto all of it.Promisesasync / await
  4. Errors and exception handling18 minWhy `try/catch` misses asynchronous failures, what `finally` really guarantees, and how to build error types worth catching.Error handling
  5. Generators18 minFunctions that pause and resume, the two-way channel `yield` opens, and the lazy sequences they make possible.Generators
  6. Prototype17 minThe chain every object has, how a lookup walks it, and the difference between `__proto__`, `prototype` and `Object.create`.Prototypes
  7. Inheritance20 minThe `extends` and `super` keywords, the pre-class pattern they replaced, and why composition is usually the better answer.Inheritance
  8. Proxy and Reflect20 minIntercepting the fundamental operations on an object, the traps worth knowing, and why `Reflect` belongs in every handler.Proxy & Reflect
  9. Deep merge and deep copy23 minWhy the spread is not enough, the three ways to copy a whole structure, and a merge function that handles the cases that break naive ones.ImmutabilityObjects
  10. Web APIs15 minThe browser's own capabilities — workers, sockets, storage, observers and fetch — and the line between them and the language.Web APIs
  11. Build tooling11 minWhat a bundler actually produces, why transpiling and bundling are different jobs, and the terms you are expected to use correctly.Tooling

Patterns & principles

10 of 10 written · 32 quiz questions →

The part of a senior interview that is not about the language. Every pattern here is shown the way JavaScript actually expresses it — closures and modules rather than class diagrams.

  1. The Module pattern15 minPrivate state from a closure, a small public surface, and why ES modules made the classic IIFE version mostly history.Design patterns
  2. The Factory pattern15 minA function that returns an object, why that beats a constructor more often than people expect, and where the memory cost shows up.Design patterns
  3. The Singleton pattern14 minOne instance, shared everywhere — why an ES module already is one, and the reasons to be careful about reaching for it.Design patterns
  4. Observer and Pub/Sub13 minOne object notifying many, the broker that decouples them further, and the unsubscribe everybody forgets.Design patterns
  5. The Strategy pattern13 minInterchangeable algorithms chosen at runtime — which in JavaScript is usually an object of functions replacing a growing switch.Design patterns
  6. The Builder pattern14 minConstructing something complicated one readable step at a time, and the two JavaScript features that make most builders unnecessary.Design patterns
  7. The Iterator pattern16 minWalking a collection without knowing how it stores things — a pattern JavaScript built into the language as a protocol.Design patterns
  8. The Repository pattern15 minOne boundary between your domain and wherever the data actually lives, so the rest of the app never learns the difference.Design patterns
  9. DRY, KISS and YAGNI13 minThree principles that pull against each other, what each one actually asks for, and when following one is the wrong call.PrinciplesGood practice
  10. SOLID in JavaScript16 minThe five principles translated out of class diagrams into functions, modules and closures — including the two that change shape without interfaces.Principles