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
Coercion and the dead zone
What == converts, and whether a line throws or prints.
Closures and this
How many bindings a loop made, and which receiver won.
Arrays, patterns and copies
What a method wrote through, and what a copy still shares.
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
Coercion, and the two equals
~49 minRun 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
Hoisting and the dead zone
~40 minSay 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
Closures, one loop at a time
~39 minCount 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
Where this comes from
~40 minFind 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
Arrays: what survives a call
~35 minSay 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
Destructuring and copies
~39 minName 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
The chain, and the referee
~1hWalk 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
More in Languages
Keep going
Python Foundations
Read a program before you run it. Then write one worth showing.
Foundational~6h8 modules
Python Fluency
Choose the shape before you type. Then say it in one line.
Intermediate~5h7 modules
Python Confidence
Somebody else wrote it. Find out whether it works.
Advanced~7h7 modules
Python Craft
It works. Now make it somebody else's.
Advanced~10h7 modules
Know what it prints before you run it.
The first item is free. ~5h of focused work, at your own pace.
Intermediate~5h7 modules