Composition over inheritance is a widely-cited design principle — favoring building objects by combining behaviors (composition) rather than inheriting from base classes (inheritance). Inheritance has significant drawbacks that composition avoids, though both have their place.
Inheritance vs composition
INHERITANCE → a class EXTENDS another, inheriting its behavior ("IS-A" relationship):
class Dog extends Animal
COMPOSITION → a class is BUILT FROM other objects/behaviors ("HAS-A" / uses):
class Car { constructor() { this.engine = new Engine(); } } // composes behaviors
→ composition: combine smaller pieces; inheritance: derive from a parent
