Using throw to simulate abstract classes

So far, we've seen how to create and combine classes into a variety of different shapes. Sometimes, however, we want to be able to prevent the creation of a class and only allow instances of extending classes. Other languages provide a facility known as abstract classes. In this recipe, we'll see how to simulate this by throwing errors.

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.