← TypeScript learning pathTypeScript · Module 6 of 10
Classes
Use typed classes with access modifiers and interfaces.
📖 Key ideas
- class Student { constructor(public name: string) {} }
- public, private, protected control access.
- readonly fields can only be set once.
- implements makes a class follow an interface.
- 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