Inheritance and Composition

In this chapter, we will cover the following recipes:

  • Extending a class
  • Assigning additional properties with constructor arguments
  • Overriding parent class instance methods
  • Overriding parent class static methods
  • Calling super methods
  • Using composition rather than inheritance to add behavior
  • Using mix-ins to add behavior
  • Passing a class as an argument
  • Checking class inheritance with Object.getPrototypeOf
  • Using throw to simulate abstract classes

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.