TypeScript
TypeScript Access ModifiersTypeScript Access Modifiers
Access Modifiers protect class data from being changed accidentally.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
In normal JavaScript, anyone can reach inside a class and change its data. TypeScript introduces Access Modifiers, which act like security guards. They decide exactly which parts of the code are allowed to view or modify specific class properties.
Key Points
- `public` allows any code anywhere to access the data (this is the default).
- `private` completely locks the data so only the class itself can see it.
- `protected` allows the class and any child classes to access the data.
- They prevent other developers from breaking the class logic.