JavaScriptIntermediate~5h

JavaScript Foundations

The language you were handed, not the one you write

Somebody hands you a file full of var, == and a method that lost its receiver, and asks what it does. Seven mechanisms decide the answer — coercion, the dead zone, closures, this, array mutation, copying and the prototype chain — each opened with a prediction you get wrong, then drilled until you do not.

Modules
7
Drills
16
Build steps
1
Time
~5h

Walk out able to

Read a snippet you did not write and say what it evaluates to, and which rule of the language decided it, before running anything.

What you learn to predict

01

Coercion and the dead zone

What == converts, and whether a line throws or prints.

02

Closures and this

How many bindings a loop made, and which receiver won.

03

Arrays, patterns and copies

What a method wrote through, and what a copy still shares.

04

The prototype chain

Which object supplied the property, and what shadowing did.

The pitch

What you practise, and what you leave with

Not an artifact — a reflex, and one file at the end: five predictions written down before the program is run, then refereed by a real engine.

You will practise

  • Coercion, == against ===, and typeof
  • Hoisting, the dead zone, and closures
  • The four this bindings, and array mutation
  • Copies, prototypes, and spotting a broken line

Afterwards you can

  • Run the == algorithm on any pair
  • Say whether a line throws or prints
  • Name which this binding wins
  • Say what a shallow copy still shares

Modules

7 modules, 38 items

Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.

  1. 1

    Coercion, and the two equals

    ~49 min

    Run the loose-equality algorithm on any pair, and say what === would have given.

    • LessonWhat this project is for4 min
    • LessonRun the equality algorithm by hand8 min
    • LessonSettle null against everything else6 min
    • DrillName the type the engine sees9 min
    • DrillPredict a coerced value11 min
    • DrillSettle == before you run it11 min
  2. 2

    Hoisting and the dead zone

    ~40 min

    Say of any line whether it throws, prints undefined, or prints a value.

    • LessonRead a file in two passes7 min
    • LessonSay which scope the binding landed in7 min
    • LessonTell the two ReferenceErrors apart5 min
    • DrillSay what the program does10 min
    • DrillSay which binding the name found11 min
  3. 3

    Closures, one loop at a time

    ~39 min

    Count the bindings a loop makes, and say what each function kept hold of.

    • LessonCount the bindings a loop makes6 min
    • LessonThree spellings of one fix5 min
    • LessonUse the same mechanism on purpose6 min
    • DrillSay what the closure kept11 min
    • DrillTrack the state a closure keeps11 min
  4. 4

    Where this comes from

    ~40 min

    Find the call site, name which of the four rules wins there, and predict the value.

    • LessonFind the call site, then find this7 min
    • LessonThe arrow, which has no rule6 min
    • LessonSettle two rules at one call site6 min
    • DrillName the binding rule that wins10 min
    • DrillPredict a detached method11 min
  5. 5

    Arrays: what survives a call

    ~35 min

    Say of any array method whether it writes through, and read the array afterwards.

    • LessonAsk a call two questions5 min
    • LessonLearn the nine that mutate5 min
    • LessonTrack two names for one array5 min
    • DrillSay whether it writes through9 min
    • DrillRead the array after the calls11 min
  6. 6

    Destructuring and copies

    ~39 min

    Name every binding a pattern makes, and say what the copy still shares.

    • LessonName every binding a pattern makes6 min
    • LessonFind the copy hiding in the rest6 min
    • LessonSay what an argument handed over6 min
    • DrillBind a destructuring pattern10 min
    • DrillSay what the copy still shares11 min
  7. 7

    The chain, and the referee

    ~1h

    Walk a chain by hand, spot a broken line at speed, then referee your own predictions.

    • LessonWalk a prototype chain by hand6 min
    • LessonSay where a write lands5 min
    • LessonFind the value every instance shares6 min
    • DrillName what supplies the property10 min
    • DrillShadow a property and re-read it11 min
    • DrillSpot the broken line12 min
    • Build stepReferee your own predictions14 min

Know what it prints before you run it.

The first item is free. ~5h of focused work, at your own pace.

Intermediate~5h7 modules