Skip to main content Accessibility Feedback

Composition vs. inheritance in JavaScript

Confession time: I don’t use or like Object-Oriented Programming (OOP). I find functional programming easier to understand, easier to write, and easier to maintain.

But OOP is an important concept in JavaScript, and it’s worth understanding how it works and when and why you might use it. One of the big decisions you make when using OOP is whether to use inheritance or composition—two different approaches to the same problem.

This amazing video from Steve Griffith does an amazing job explaining the differences between the two, and when and why you’d pick one over the other.

Steve explains a complex topic with a fun, simple example. Along the way, you also learn a bit more about OOP in general.

Thanks for this awesome resource, Steve!