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:
constructorprototype methodsstatic 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
extendsa another class, it must callsuper()before accessingthisin the constructor.
Last updated