Summary

In this chapter, we focused on understanding ES6 classes. ES6 classes give formal support to the common JavaScript pattern of simulating class-like inheritance hierarchies using functions and prototypes. They are syntactic sugaring over prototype-based OO, offering a convenient declarative form for class patterns which encourage interoperability. ES6 classes offer a much nicer, cleaner, and clearer syntax for creating these objects and dealing with inheritance. ES6 classes provide support for constructors, instance and static methods, (prototype-based) inheritance, and super calls.

So far, JavaScript lacked one of the most basic features - modules. Before ES6, we wrote modules using either CommonJS or AMD. ES6 brings modules into JavaScript ...

Get Object-Oriented JavaScript - Third Edition 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.