Introduction
Creating and extending similar objects has always been possible with JavaScript's prototypical inheritance model. By using the new
operator and adding prototype properties, we can create structures that behave like classes.
ECMAScript 2015 introduced class syntax as a friendlier way to work with prototypical inheritance. It has been argued that this syntactic sugar is not worth the overhead of having two ways to implement OOP structures. However, I would argue that class provides a more concise way of expressing the same idea, and is a net benefit. As we'll see in this chapter and the next, the class syntax makes it easier to express sophisticated OOP relationships.