Skip to main content
D
TypeScript
TypeScript Access Modifiers

TypeScript Access Modifiers

Access Modifiers protect class data from being changed accidentally.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

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.

Up Next

Continue your journey with the next topic.

Go to TS Decorators