Reuse behavior with inheritance.
Section: Classes
Extend a class
typescript
typescript
class Animal {
move() {
return "moving";
}
}
class Bird extends Animal {
fly() {
return "flying";
}
}Explanation
Inheritance works well for simple hierarchies, though composition is often easier to maintain.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Classes
Use access modifiers
Control visibility with `public`, `private`, and `protected`.
Use an abstract class
Require derived classes to implement specific methods.
Use getters and setters
Wrap computed or validated access around fields.