koans.app

JavaScript Koans

JavaScript is the language every web browser understands. It makes pages interactive, and it runs on servers and in tools and apps too. It’s flexible and forgiving: functions are values, objects are everywhere, and much of its power is in handling things that happen later, like clicks and network replies. These koans start with its values and famous quirks, and go on to arrays and objects, closures, classes, iterators and async code.

89 koans in 16 groups, tested with Vitest. Each is a small program whose tests fail: replace every ___ until they pass.

Start the path

Awakening

How a koan checks your answers, and how JavaScript compares and checks values.

  1. Expectations
  2. Equality
  3. typeof
  4. Truthiness
  5. null and undefined
  6. Errors

Numbers

One number type for integers and fractions, its surprises, and BigInt.

  1. Arithmetic
  2. Floating point
  3. Special numbers
  4. Conversion
  5. Math
  6. BigInt
  7. Typed arrays

Strings

Template literals, slicing, methods, Unicode, and regular expressions.

  1. Template literals
  2. Indexing and slicing
  3. String methods
  4. Split, join and pad
  5. Comparing strings
  6. Unicode
  7. Regular expressions

Variables and scope

let, const and var, blocks, and hoisting.

  1. let and const
  2. Block scope
  3. Hoisting
  4. Destructuring

Control flow

Choosing and repeating: if, switch, the loops, break and continue, and the operators that short-circuit.

  1. Conditionals
  2. switch
  3. Loops
  4. for…in
  5. break and continue
  6. Short-circuit operators

Arrays

Lists of values: changing them, copying them, searching and transforming them.

  1. Arrays
  2. Slice and splice
  3. Map, filter and reduce
  4. Searching
  5. Sorting
  6. Copying arrays
  7. Iterating arrays
  8. Building arrays
  9. Grouping

Objects

Keyed data: building objects, taking them apart, copying, freezing, and reading safely.

  1. Objects
  2. Shorthand and computed keys
  3. Spread and rest
  4. Object methods
  5. Getters and setters
  6. Freezing
  7. Optional chaining and nullish

Maps, sets and symbols

The collections built for keyed data and unique values, and symbols.

  1. Maps
  2. Sets
  3. Set operations
  4. Symbols
  5. Weak collections

Functions

Functions as values: declarations, arrows, parameters, closures, this, and recursion.

  1. Declarations and expressions
  2. Arrow functions
  3. Parameters
  4. Closures
  5. Higher-order functions
  6. this
  7. Recursion

Classes and prototypes

Classes, inheritance, private fields, and the prototypes underneath.

  1. Classes
  2. Inheritance
  3. Private and static
  4. Getters and setters in classes
  5. Prototypes
  6. Mixins

Iterators and generators

The iteration protocol, generator functions, and making your own iterables.

  1. Iterables
  2. Generators
  3. Delegation
  4. Custom iterables
  5. Iterator helpers
  6. Async iteration

Async

Promises, async functions, combinators, errors, and the event loop.

  1. Promises
  2. async and await
  3. Promise combinators
  4. Async errors
  5. The event loop

Errors

Catching, cleaning up, your own errors, and causes.

  1. try, catch and finally
  2. Custom errors
  3. Error causes

JSON, dates and Intl

Data in and out: JSON, dates, and formatting for people.

  1. JSON
  2. Dates
  3. Intl

Metaprogramming

Code about code: proxies, Reflect, and tagged templates.

  1. Proxies
  2. Reflect
  3. Tagged templates

Puzzles

Small programs that put the path together: read them closely and predict what they do.

  1. FizzBuzz
  2. Word count
  3. Run-length encoding
  4. Roman numerals
  5. Matrix tricks