Chapter 8. Classes and Modules
In this chapter, we will explore some of the most interesting features introduced in ES6. JavaScript is a prototype-based language and supports prototypical inheritance. In the previous chapter, we discussed the prototype property of an object and how prototypical inheritance works in JavaScript. ES6 brings in classes. If you are coming from traditional object-oriented languages such as Java, you will immediately relate to the well-known concepts of classes. However, they are not the same in JavaScript. Classes in JavaScript are a syntactic sugar over the prototypical inheritance we discussed in the last chapter.
In this chapter, we will take a detailed look at ES6 classes and modules - these are welcome changes to this edition of JavaScript and make Object Oriented Programming (OOP) and inheritance significantly easier.
If you are coming from a traditional object-oriented language, prototypical inheritance may feel a bit out of place for you. ES6 classes offer...