Engrain by ByteRush

JS.04.04 Mid-level

Inheritance patterns and composition

Comes up in: Low-level design, JavaScript

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • prototypal vs classical
  • mixins
  • composition over inheritance
  • extending built-ins (Array, Error) caveats
  • Symbol.species (awareness)

Words you will know

mixincompositiondelegation

What you will practise

  • refactor deep inheritance to composition

Interview questions this answers

  • Explain prototypal inheritance.
  • Composition vs inheritance: when do you choose each?