Caffeinated Coder
Book an appointment
Lesson 10 · Core type system

Classes in TypeScript

A class is a blueprint for objects. Follow a twelve-line program as new builds two objects, the constructor fills their fields, and a method changes one object's balance through this, until 75 is printed. Then see TypeScript's part: typed fields, a private balance that tsc refuses to let outside code touch, and why that check is erased from the JavaScript that runs.

11 min8 steps5 questionsBeginner
Fig 10 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.