TYPESCRIPTChapter 2 · TS Unions & Enums
Classes and visibility modifiers
TypeScript classes extend JavaScript classes by adding types and visibility modifiers: public (accessible anywhere), private (accessible only inside the class), and protected (accessible inside the class and its subclasses).
Worked example
How it reads
- private altitude prevents external access to this property
- public name allows normal reading and writing from outside

Cloud tip: You can declare class properties directly in the constructor parameters as public/private as a shorthand.


