May 2019
Intermediate to advanced
316 pages
7h 13m
English
Class definition in ES6 is similar to other object-oriented languages, such as Java or C#. The keyword for defining the classes is class. The class can have fields, constructors, and class methods. The following sample code shows the ES6 class:
class Person { constructor(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } }
Inheritance is performed with an extends keyword. The following sample code shows an Employee class that inherits a Person class. This means that it inherits all fields from the parent class and can have its own fields that are specific to the Employee. In the constructor, we first call the parent class constructor by using the super keyword. That call is required by the ...
Read now
Unlock full access