0Pricing
TypeScript Academy · Lesson

public, private, and protected Modifiers

Control access to class members with modifiers.

Welcome

TypeScript access modifiers control the visibility of class members. They help enforce encapsulation and prevent unintended usage.

public: Accessible Everywhere

public is the default. Public members are accessible from anywhere — inside the class, subclasses, and external code.
class Car {
  public brand: string;
  constructor(brand: string) { this.brand = brand; }
}
const c = new Car('Toyota');
console.log(c.brand); // OK

All lessons in this course

  1. TypeScript Classes and Constructors
  2. public, private, and protected Modifiers
  3. readonly Properties and Parameter Properties
  4. Implementing Interfaces with Classes
← Back to TypeScript Academy