Module 9 · this, Prototypes and Classes
Class, Closure or Plain Object: Choosing How to Bundle Data with Behaviour
Free with an accountReading
Rafi's team is rewriting a phone app's settings and its app switcher. One teammate wants a class for everything. Another, fresh from Module 6, wants closures for everything. A third says plain objects are enough. They are all partly right. Each shape bundles data with behaviour, and each one is best at something different.
Checking what this lesson needs for you…
What is inside Class, Closure or Plain Object: Choosing How to Bundle Data with Behaviour
- Three ways to make a counter
- Shared methods against one copy per object
- Privacy: a # field or a closure
- this: the closure never needs it
- instanceof and inheritance
- What each one costs
- The comparison table
- Choosing by four questions