If you are trying to get a good understanding of what’s composition vs inheritance, you probably search on google etc., read articles and watch videos around “composition vs inheritance”. Here’s the problem, you are going to learn incorrect definition of composition.
This is coming from a book written in 1994.
“Favor object composition over class inheritance”
— Design Patterns: Elements of Reusable Object-Oriented Software (page 20)
The majority of sources around “composition vs inheritance” has a huge misconception about the composition itself. But they use the statement above as a sign post, saying, hey, we should favor composition over inheritance. Actually this is one of the most misunderstood statements ever in the JS community. And the problem is not about the statement above, the statement itself is correct, the author gave a very strong argument why we should favor one over the other. The problem is that we have tons of beginners in JS community who get wrong mindset around composition, and tons of engineers who write weird code, thinking these authors were saying one thing, while in fact they meant something very different.