Classes
Explore how classes provide a modern approach to object-oriented programming in JavaScript. Understand constructors, class methods, static methods, and inheritance using extends and super. Gain the skills to write cleaner, more efficient code leveraging ES2015+ class features.
We'll cover the following...
Classes in JavaScript are nothing more than special functions. They are created by using the class keyword and being given a name. Like a normal function, when invoked with new, a class returns an object.
Class constructor
Classes have a special method on them called constructor. This is the method that is invoked when the class is invoked. Think of the constructor method as the function body of the class.
We add methods on a class as if it were an object.
We can see that calling new Person() results in the class constructor method ...