Language basics
43 steps in 10 sets of JavaScript.
Forty-three steps of the language itself, no browser and no Node. Bindings, text, control flow, functions, arrays, objects, classes, errors, and JSON.
It is the longest JavaScript tour here because the language has accumulated a lot and none of it was ever removed. Learning which subset to write is most of the skill, and it starts by having typed the options.
Bindings & values
- Variables and template literalsBindings and string interpolation, the modern defaults.
- let, const and the dead zoneBlock scoping, and why a let is unusable before its declaration.
- Equality and coercion=== compares without converting; == converts first, and surprises.
- Optional chaining and nullish?. stops at null or undefined; ?? only falls back on those two.
- NumbersOne float type, so integer checks and precision need care.
Text
- String methodsThe methods worth knowing, including the newer ones.
- Template literalsInterpolation, multiline strings, and the tagged form.
- Title caseCapitalizes each word, with the small words most implementations get wrong.
- Human-readable bytesTurns a byte count into something a person can read.
- RGB to hexConverts between the two color notations CSS accepts.
Control flow
- Loops and iterationfor...of, classic for, and iterating object entries.
- FizzBuzzThe classic screening exercise for loops and conditionals.
- Range generatorA generator that yields numbers lazily, so an enormous range costs nothing.
Functions
- Functions and closuresDeclarations, arrows, defaults, rest, and closures.
- DestructuringPulling values out of objects and arrays by shape.
- Destructuring, furtherDefaults, renaming, nesting, and pulling apart function parameters.
Arrays
- Array methodsThe iteration methods that replace most for loops.
- Iterating arraysThe method decides what comes back: a value, a boolean, or a new array.
- Copying instead of mutatingThe 2023 methods return a new array where the old ones edited in place.
- Chunk an arraySplits an array into fixed-size pieces, for batching requests or laying out a grid.
- Flatten nested arraysFlattens nested arrays to any depth, recursively.
- Unique by keyDeduplicates by a computed key rather than by identity.
- Zip arraysPairs up parallel arrays into tuples, stopping at the shortest.
- Fisher-Yates shuffleFisher-Yates, the shuffle that is actually uniform, unlike sorting by a random comparator.
- Median of numbersThe middle value, which needs a sort and a decision about even-length input.
- Binary searchHalve the range each step; a thousand items takes ten comparisons.
Objects & collections
- ObjectsSpreading, inspecting, and safely reading objects.
- Working with objectsKeys, values, entries, spread, and the two kinds of freeze.
- Map and SetKeyed collections with any key type, and unique sets.
- Map, Set and their weak cousinsMaps take any key and remember insertion order; WeakMap holds no reference.
- Group by keyTurns a flat array into an object keyed by whatever you pick out of each item.
- Count by keyTallies how many items fall under each computed key.
- Shallow object equalityCompares objects one level deep, which is what a re-render check needs.
- Deep cloneCopies a nested structure so that changing the copy leaves the original alone.
Classes
- ClassesClass syntax with inheritance and static members.
- Classes, the modern partsField declarations, private members, static blocks and accessors.
- Extending a classextends, super, and how instanceof sees the chain.
Errors
- Custom errorsSubclassing Error to carry structured failure data.
- Errors that carry a causeA custom Error subclass, with the original attached.
Data formats
- JSONSerializing and parsing, with error handling.
- Regular expressionsMatching, extracting, and replacing with regex literals.
- Parse a query stringPulls a query string apart into an object, repeated keys included.
Encore
- word-count.jsA complete word-frequency script: read a file, normalize, tally, report.