Classes

Classes

Are a special type of function that act as a template for object creation.

  • Classes dont suffer hoisting.

  • They are similar to Constructor Functions.

// Class Declaration
class SomeClass {

}

// Class Expression
const SomeClass = class {

}

They have 3 different member types:

  • constructor

  • prototype methods

  • static methods

constructor

Is invoked at the moment of the class instanciation, and serves to initialize a object.

prototype methods

They depend on a created instance to be invoked.

static methods

Dont depend in created instances.

extends

Used to create a ``class` hierarchy.

When a class extends a another class, it must call super() before accessing this in the constructor.

Last updated