Purpose and Intended Audience Beginning with ECMAScript 6, JavaScript supports object-oriented programming with classes. Before that, OOP was supported only by means of constructor functions and prototypes rather than classes. In view of the fact that we all have to deal with legacy code every once in a while, JavaScript programmers are well-advised to study the old way of doing OOP in JavaScript, despite the fact that they will probably not use it in their own code. This article explains legacy OOP in Javascript with constructor functions and prototypes. The article was written before the decision to incorporate classes in JacaScript was made. It therefore gives a true account of what OOP in JacaScript was before classes.
Prerequisites
Omissions |