typestar

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.

Start this tour

Bindings & values

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

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

Errors

Data formats

Encore

  • word-count.jsA complete word-frequency script: read a file, normalize, tally, report.

The other JavaScript tours