Tag Archives: Classes

Classes Javascript

Introduced in the ES6 version, classes are nothing but syntactic sugars for constructor functions.

They provide a new way of declaring constructor functions in javascript.

Unlike functions, classes are not hoisted. A class cannot be used before it is declared.

A class can inherit properties and methods from other classes by using the extend keyword.

All the syntaxes inside the class must follow the strict mode(‘use strict’) of javascript. Error will be thrown if the strict mode rules are not followed.

Factory Classes

Factory classes provide an interface for creating families of related objects. Factory classes are useful when the decision of which class to use must be done at run time and cannot be hard coded during development. Factory classes encapsulate the logic needed to decide which subclass to instantiate and so removes this decision from the application, delegating it to the factory.