3 Different Kinds of Prototypal Inheritance: ES6+ Edition

Eric Elliott
May 30, 2016 · 8 min read
Triplets — Phil Dolby (CC-BY-2.0)
Recorded at the O’Reilly Fluent conference, 2013

Delegation / Differential Inheritance

The Prototype Chain

Concatenative Inheritance / Cloning / Mixins

Functional Inheritance

Composition Over Class Inheritance

“Favor object composition over class inheritance.” ~ The Gang of Four, “Design Patterns: Elements of Reusable Object Oriented Software

const effect = compose(delay, distortion, robovoice); // Rock on!

When would you want to use class inheritance? For me, the answer is simple: “Never.”

Composition is:

Stamps

Descriptor

Why Stamps?

What About `class`?

Inheritance in JavaScript is so easy, it confuses people who expect it to take effort. To make it harder, we added `class`.

Conclusion


Learn JavaScript with Eric Elliott


JavaScript Scene

JavaScript, software leadership, software development, and related technologies.

Thanks to Vasyl Boroviak.

Eric Elliott

Written by

Make some magic. #JavaScript

JavaScript Scene

JavaScript, software leadership, software development, and related technologies.