← TypeScript learning path
TypeScript · Module 6 of 10

Classes

Use typed classes with access modifiers and interfaces.

📖 Key ideas

  1. class Student { constructor(public name: string) {} }
  2. public, private, protected control access.
  3. readonly fields can only be set once.
  4. implements makes a class follow an interface.
  5. abstract classes define methods children must implement.
💡 Real-life example: Access modifiers are rooms in a house: public is the hall, private is your bedroom.
privateAccessible only inside the class
protectedAccessible in class and subclasses
implementsClass follows an interface
abstractCannot be instantiated directly