← Back to JavaScript

JavaScript — Quick Summary

Quick revision: every topic, key terms, and mnemonics for JavaScript.


This is a quick revision doc covering all 43 topics in the JavaScript collection. Open the linked notes if you want depth — this page is for cementing what we already know, fast.

Fundamentals

let, const, and var

What it is. Three ways to declare variables. var is function-scoped, let and const are block-scoped. const cannot be reassigned (but its object/array contents can mutate).

Key terms.

Remember. Default to const. Reach for let only when reassigning. Avoid var in modern code.

Data Types & Type Coercion

What it is. JS has 7 primitives (string, number, boolean, null, undefined, symbol, bigint) and reference types (objects, arrays, functions). Primitives are compared by value; references by identity.

Key terms.

Remember. “Empty array, empty object — both truthy. typeof null lies.”

Hoisting

What it is. Before code runs, JS scans declarations and “moves” them to the top of their scope. var is initialized as undefined; let/const are hoisted but in TDZ; function declarations hoist fully (callable before their line).

Key terms.

Remember. “Functions hoist whole. var hoists empty. let/const hoist but bite.”

use strict

What it is. A directive ("use strict";) that turns silent JS gotchas into real errors — no implicit globals, no duplicate parameter names, no assignments to read-only properties.

Remember. Strict makes “bad syntax” loud. ES Modules and classes are already strict by default.

Destructuring

What it is. Unpacking values from objects/arrays into variables in one expression. {} for objects (match by name), [] for arrays (match by position).

Key terms.

Spread & Rest

What it is. Same ... syntax, opposite jobs. Spread expands an iterable into individual elements. Rest collects multiple elements into one array/object.

Key terms.

Remember. “Giving = spread. Getting = rest.”

Template Literals

What it is. Backtick strings that support ${expr} interpolation and multi-line text. Tagged templates let a function process the parts (e.g. styled-components, graphql-tag).

Remember. Backtick beats + every time.

Functions

Arrow Functions

What it is. ES6 shorter function syntax (a, b) => a + b. They have no own this, no arguments, can’t be used as constructors (new throws).

Key terms.

Remember. Arrows steal this from their parent. Don’t use them as object methods if you need this to be the object.

Higher-Order Functions

What it is. Functions that take a function as an argument or return a function. Foundation of functional JS.

Key terms.

Remember. Declarative > imperative. arr.filter(...).map(...) reads top-to-bottom.

Closures

What it is. A function bundled with references to its surrounding lexical scope. Every function in JS is technically a closure.

function counter() {
  let count = 0;
  return () => ++count;
}

Key terms.

Remember. Closures are how setTimeout/setInterval/event handlers remember their context.

Currying

What it is. Transforming f(a, b, c) into f(a)(b)(c) — a chain of unary functions. Useful for partial application: multiply(2) becomes double.

const multiply = a => b => a * b;
const double = multiply(2);

Memoization

What it is. Cache function results keyed by arguments. Same input → return cached output instead of recomputing. Pure functions only.

Remember. Stringify args (JSON.stringify) to make a cache key. Common in fib, API responses, expensive UI calculations.

Call, Apply and Bind

What it is. All three set what this is when a function runs. call invokes immediately with args one-by-one. apply invokes immediately with an args array. bind returns a new function with this permanently fixed (does NOT call).

Key terms.

Remember. “Call = comma. Apply = array. Bind = baked-in.”

IIFE

What it is. Immediately Invoked Function Expression: (function(){...})();. Runs once on definition, creates a private scope.

Remember. Pre-ES6 module pattern. Today: top-level await wrapper (async () => { ... })().

Scope & Execution

Lexical Scope

What it is. Inner functions can read variables from outer (parent) scopes, but not the other way around. Determined at write-time, not call-time.

Remember. “Where the function is written decides what it can see.”

Execution Context

What it is. Box that holds variables, functions, and this for each running piece of code. Two phases: Creation (memory allocated, hoisting happens) and Execution (line-by-line). Stored in the Call Stack.

Key terms.

The this Keyword

What it is. this depends on how a function is called.

Key terms.

Remember. “Look at the left side of the dot when called — that’s this.”

Shallow Copy & Deep Copy

What it is. Shallow copy duplicates the top level only — nested objects still share references. Deep copy recursively copies everything.

Key terms.

Async JavaScript

Callbacks

What it is. A function passed as an argument to be “called back” later. Sync (map, forEach) or async (setTimeout, fs.readFile).

Key terms.

Promises

What it is. An object representing the future result of an async operation. States: pending, fulfilled, rejected. Once settled, never changes.

Key terms.

Remember. Promises flatten callback hell. .catch at the end catches errors from any upstream .then.

Async/Await

What it is. Syntactic sugar over Promises. async functions always return a Promise. await pauses inside the async function until the awaited Promise settles.

Key terms.

Promise Methods

What it is. Four static helpers for handling multiple Promises.

MethodResolves whenRejects when
Promise.allALL resolveANY rejects (fail-fast)
Promise.allSettledALL settleNever
Promise.raceFirst to settle (resolve OR reject)First to settle (if reject)
Promise.anyFirst to resolveALL reject (AggregateError)

Remember. “all = all-or-nothing, allSettled = no-fail-status-report, race = first-finisher, any = first-success.”

Error Handling

What it is. try/catch/finally for synchronous failures; .catch or try/catch with await for async. Throw Error instances (not strings) for stack traces.

Key terms.

Event Loop

What it is. JS is single-threaded. The event loop coordinates the Call Stack, Web APIs, Microtask Queue (Promises, queueMicrotask, MutationObserver, async/await continuations), and Callback Queue (setTimeout, setInterval, I/O).

Key terms.

Remember. “Sync first → drain microtasks → one macrotask → drain microtasks → repeat.”

console.log(1);
setTimeout(() => console.log(2), 0);
Promise.resolve().then(() => console.log(3));
console.log(4);
// 1, 4, 3, 2

Debouncing and Throttling

What it is. Two ways to rate-limit a function for rapid events.

Key terms.

Remember. “Debounce waits for silence. Throttle ticks on a clock.”

Objects & Prototypes

Objects

What it is. Key-value bags. Created via literals {}, constructor functions (new Foo()), or Object.create(proto).

Key terms.

Prototypal Inheritance

What it is. Every object has a hidden link [[Prototype]] to another object. Property lookup walks the chain until found or until null.

Key terms.

Remember. Classes are sugar over this. Methods on prototype are shared once across all instances.

Classes

What it is. ES6 syntactic sugar over constructor functions and prototypes. Provides constructor, methods, extends/super, static, private #field, getters/setters.

Key terms.

Remember. typeof Class === "function" — classes are functions.

Iterators: for…in vs for…of

What it is. for...in iterates keys (including inherited enumerable ones). for...of iterates values of any iterable (arrays, strings, Maps, Sets).

Remember. “in for keys, of for values.” Don’t use for...in on arrays.

Map & Set

What it is.

DOM & Events

Events

What it is. Notifications fired when something happens in the page (click, load, keypress, scroll, etc.). JS handlers respond.

Event Bindings

What it is. addEventListener (multiple handlers, third-arg options like once, capture, passive) vs onclick property (single handler, gets overwritten). removeEventListener needs the same function reference.

Event Propagation, Bubbling and Capturing

What it is. Three phases when an event fires:

  1. Capturing — top → target.
  2. Target — fires on the actual element.
  3. Bubbling — target → top (default for handlers).

addEventListener(type, fn, true) runs in the capture phase. event.stopPropagation() halts the chain.

Event Delegation

What it is. One listener on a parent uses event.target to handle events from any descendant. Replaces N listeners with 1.

Key terms.

Remember. “Listen up high, ask event.target who fired it.” Auto-supports dynamically added children.

DOM Manipulation

What it is. Selecting (getElementById, querySelector, querySelectorAll), creating (createElement, createTextNode), modifying (textContent, innerHTML, setAttribute, classList.add/remove/toggle), inserting (appendChild, append, prepend, insertBefore), and removing (element.remove()).

Remember. Prefer textContent over innerHTML for plain text — faster and XSS-safe.

Web Storage & Cookies

What it is.

Remember. Server needs it on every request → cookie. Otherwise → localStorage (persistent) or sessionStorage (tab-only).

ES6+ & Modern JS

Modules

What it is. Per-file scoping with explicit export/import. Named exports keep the same identifier; default exports can be renamed. Dynamic import('./mod.js') returns a Promise — used for code splitting.

Key terms.

Optional Chaining & Nullish Coalescing

What it is.

Remember.?? keeps falsy-but-real values. || nukes them all.”

Symbols

What it is. Primitive that’s always unique. Used as object keys that won’t clash with anything else; not enumerable in for...in/Object.keys/JSON.stringify.

Key terms.

Proxy & Reflect

What it is. Proxy wraps an object with handler traps (get, set, has, deleteProperty, apply, …) that intercept operations. Reflect provides static methods matching every trap so we can forward to the default behavior cleanly.

Remember. Vue 3’s reactivity is built on Proxy. Useful for validation, logging, observable state.

Patterns & Practice

Output-Based Questions

What it is. Classic “what prints?” interview ammo. Common categories:

Remember. When stuck: identify if it’s hoisting, coercion, this, or event loop — those four cover almost every trick.

Polyfills

What it is. Re-implementing built-ins to prove deep understanding.

Array.prototype.myMap = function(cb, thisArg) {
  const out = [];
  for (let i = 0; i < this.length; i++)
    if (i in this) out.push(cb.call(thisArg, this[i], i, this));
  return out;
};

Function.prototype.myBind = function(thisArg, ...bound) {
  const fn = this;
  return function(...rest) { return fn.apply(thisArg, [...bound, ...rest]); };
};

Remember. Callback signature is (element, index, array). reduce without initial value uses arr[0] and starts from index 1.

Design Patterns

What it is. Four patterns that come up constantly.

PatternIdeaReal-world
ModuleClosure-based private state + public APIjQuery, pre-ESM libraries
SingletonSingle shared instanceRedux store, DB connections
Observer (pub/sub)Subscribe + notifyEventEmitter, addEventListener, RxJS, Vue reactivity
FactoryFunction returns objects without newReact.createElement, express()

Remember. All four are easy to write in vanilla JS — no library needed.