The
constructor method is a special method for creating and initializing an object created with a
class. There can only be one special method with the name "constructor" in a class. A SyntaxError will be thrown if the class contains more than one occurrence of a constructor method.
A constructor can use the super keyword to call the constructor of the super class.
If you don't provide your own constructor, then a default constructor will be supplied for you. If your class is a base class, the default constructor is empty:
If your class is a derived class, the
default constructor calls the parent constructor, passing along any arguments that were provided:
constructor(...args) {
super(...args);
}