JavaScript Documentation
Concise, example-driven JavaScript reference. Read the concept, see the code, then practice it in a Coddy journey.
Start a guided JavaScript journeyGetting Started
- What Is JavaScriptWhat JavaScript actually is, where it runs, what it's used for, and how it differs from Java and TypeScript — a grounded intro for beginners.
- Running JSThe practical ways to run JavaScript in 2026 — the browser console, a script tag in HTML, Node.js from the terminal, and when to reach for each.
- Syntax & SemicolonsHow JavaScript syntax works — statements, blocks, expressions — and the real story on semicolons, automatic semicolon insertion, and when it bites you.
- Strict ModeWhat JavaScript's strict mode changes, how to turn it on, and why modern code (modules and classes) gets it automatically.
- CommentsHow comments work in JavaScript — `//` for single lines, `/* */` for blocks, and the habits that make comments actually useful instead of noise.
Variables & Types
- let, const, varThe three ways to declare a variable in JavaScript — and why modern code uses `const` by default, `let` when it has to, and `var` basically never.
- Primitive TypesThe seven primitive types in JavaScript — string, number, bigint, boolean, null, undefined, symbol — and how they differ from objects.
- Strings & TemplatesHow strings work in JavaScript — quotes, backticks, interpolation, multiline text, and the methods you'll actually reach for.
- Numbers & BigIntHow JavaScript's Number type really works — floating-point precision, MAX_SAFE_INTEGER, and when to reach for BigInt instead.
- null vs undefinedWhat the difference between null and undefined actually is in JavaScript, how to check for either, and which one to reach for in your own code.
- Type CoercionHow JavaScript coerces values between types — the implicit rules that trip people up, the explicit conversions you should prefer, and when each kicks in.
- Equality OperatorsHow equality works in JavaScript — strict vs loose, the quirks of ==, how NaN and objects behave, and when to reach for Object.is.
Control Flow
- OperatorsThe operators JavaScript gives you for doing math, comparing values, combining booleans, and assigning — with the quirks that actually bite in practice.
- if / elseHow if/else works in JavaScript — conditions, else if chains, truthiness gotchas, and when to reach for the ternary operator instead.
- SwitchHow the JavaScript switch statement works — cases, break, default, fallthrough, and when switch beats a chain of if/else.
- For LoopsHow the classic `for` loop works in JavaScript — the three-part header, iterating arrays, break and continue, nested loops, and common pitfalls.
- While LoopsHow `while` and `do...while` loops work in JavaScript — when to reach for them instead of `for`, and how to avoid infinite loops.
- for...of & for...inHow for...of and for...in actually differ in JavaScript — values vs keys, arrays vs objects, and when to reach for each.
- Truthy & FalsyWhat counts as truthy and falsy in JavaScript, the full list of falsy values, and how boolean coercion plays out in real code.
Iteration
- Iterators & GeneratorsHow JavaScript's iterator protocol works, how to make your own objects iterable, and how generator functions make the whole thing painless.
- SymbolsWhat JavaScript symbols are, why they exist, and how well-known symbols like Symbol.iterator let your own objects plug into language features.
Functions
- Function DeclarationsHow to declare functions in JavaScript — the function keyword, parameters, return values, hoisting, and when to reach for a declaration vs an expression.
- Arrow FunctionsHow arrow functions work in JavaScript — the `=>` syntax, implicit returns, how they handle `this`, and when to reach for one instead of `function`.
- Parameters & DefaultsHow parameters work in JavaScript — default values, the undefined trigger, evaluation order, and the difference between parameters and arguments.
- Rest & SpreadHow the ... operator works in JavaScript — collecting arguments with rest parameters, expanding arrays and objects with spread, and when to reach for each.
- ClosuresA closure is a function that remembers the variables around it. Here's how closures work in JavaScript, with runnable examples and real use cases.
- this KeywordHow `this` actually works in JavaScript — the four binding rules, why arrow functions are different, and how to avoid the classic 'this is undefined' trap.
- Higher-Order FunctionsHigher-order functions in JavaScript — passing functions as arguments, returning them from other functions, and the map/filter/reduce patterns you'll use every day.
Objects & Arrays
- ObjectsHow JavaScript objects actually work — creating them, reading and writing properties, adding methods, and the patterns that keep object code readable.
- ArraysHow arrays work in JavaScript — creating them, indexing, length, push/pop, slice vs splice, and the loops that read cleanest.
- DestructuringHow destructuring works in JavaScript — pulling values out of objects and arrays, renaming, defaults, nested patterns, and function parameters.
- Object SpreadHow the object spread operator works in JavaScript — cloning, merging, overriding properties, and the shallow-copy gotcha that trips people up.
- Array MethodsThe array methods that replace most of your for loops — map, filter, reduce, find, some, every — and which ones mutate versus return a new array.
- Map & SetHow JavaScript's Map and Set work, how they differ from plain objects and arrays, and when reaching for them pays off.
- JSONHow to convert JavaScript objects to JSON and back — JSON.stringify, JSON.parse, the replacer and reviver hooks, and the values that don't survive the round trip.
- Optional ChainingHow the `?.` operator lets you reach into nested objects, arrays, and methods without blowing up on null or undefined.
- Nullish CoalescingHow the `??` operator picks a default only when a value is `null` or `undefined` — and why that beats `||` for most real-world defaults.
Classes & Prototypes
- ClassesHow JavaScript classes actually work — constructors, methods, instance fields, getters and setters, and the mental model behind the `class` keyword.
- InheritanceHow inheritance works in JavaScript classes — extends, super, overriding methods, and when inheritance is the wrong tool.
- Static MembersHow static methods and properties work in JavaScript classes — when to use them, how `this` behaves, and the factory pattern they enable.
- Private FieldsHow the `#` prefix makes class fields and methods truly private in JavaScript — syntax, rules, and why the underscore convention isn't enough.
- PrototypesWhat JavaScript prototypes actually are, how the prototype chain resolves property lookups, and how `class` syntax maps onto the same underlying mechanism.
Async JavaScript
- Event LoopThe mental model behind async JavaScript — the call stack, the task queue, the microtask queue, and how the event loop ties them together.
- CallbacksHow callbacks work in JavaScript — passing functions as arguments, the error-first pattern, and why nested callbacks drove the community to promises.
- PromisesHow Promises work in JavaScript — the three states, chaining with then and catch, combining with Promise.all, and writing your own with new Promise.
- async/awaitHow async/await really works in JavaScript — async functions, awaiting promises, error handling with try/catch, and running tasks in parallel.
- Fetch APIHow to use the Fetch API in JavaScript — GET and POST requests, parsing JSON, handling errors properly, and aborting slow requests.
- Async ErrorsHow errors actually flow through async JavaScript — try/catch with async/await, .catch on promises, and the traps that silently swallow failures.
Modules & Tooling
- ES ModulesHow ES modules work in JavaScript — named and default exports, import syntax, dynamic import(), and the rules that separate modules from regular scripts.
- CommonJS vs ESMThe two module systems JavaScript ships with, why both exist, and how to choose between require and import in Node projects.
- npm BasicsHow npm actually works — installing packages, init, dev dependencies, updates, and the mental model behind node_modules and the lockfile.
- package.jsonWhat lives inside package.json — the fields that matter, how scripts work, and how semver ranges decide which versions npm installs.
- Node RuntimeWhat the Node.js runtime is, how it differs from the browser, and the core APIs — globals, modules, process, fs — that make server-side JavaScript possible.
Errors & Debugging
- try/catchHow try/catch/finally works in JavaScript — catching errors, the error object, rethrowing, and when try/catch is the wrong tool.
- Error TypesThe built-in error types in JavaScript — what each one means, when you'll see it, and how to read the message without guessing.
- Console & DevToolsThe console methods and DevTools features that make JavaScript debugging faster than sprinkling console.log everywhere.
Working with Real Data
- RegexHow regular expressions work in JavaScript — creating patterns, the core methods (test, match, replace), flags, and capture groups with real examples.
- Date & TimeHow the JavaScript Date object really works — creating dates, formatting them, doing arithmetic, handling timezones, and the quirks that trip people up.
- URLs & Query StringsHow to parse, build, and modify URLs in JavaScript with the `URL` and `URLSearchParams` APIs — without regex and without edge-case bugs.