Module 6 · Scope, Hoisting and Closures
When a Closure, When a Class, When a Module
Free with an accountReading
Kenji has just learned closures, and his code review comment says "make everything a closure". His dashboard has 10,000 product rows, and he wants each row to be a counter factory with its own functions. Maria asks the question she always asks: but why not a class? Both of them are partly right. This lesson is about telling the cases apart.
Checking what this lesson needs for you…
What is inside When a Closure, When a Class, When a Module
- Kenji's 10,000 counters
- One job, three ways
- The chart: four homes for a value
- The flowchart: three questions
- When a closure goes stale
- Closures that hold too much
- const, let or var