June 2018
Intermediate to advanced
302 pages
6h 48m
English
Class definition in ES6 is similar to other object oriented languages like 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 done with an extends keyword. The following sample code shows an Employee class that inherits a Person class. Therefore, 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 and you will get an ...
Read now
Unlock full access