Is your 401k bleeding money by not offering low-cost index funds? Now there is a way to find out.

Object-Oriented Programming in JavaScript (Pre-ECMAScript 6) Explained

A Tutorial for Those Who Are Accustomed to Classes
By Thomas Becker   about me  



  1. About This Tutorial
  2. Introduction
  3. Class-Based OOP: A Simple Class Definition
  4. Constructor Functions
  5. Prototypes
  6. Static Members
  7. Inheritance
  8. Unsupported Features
  9. Acknowledgments

About This Tutorial

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.

A working knowledge of JavaScript and familiarity with a class-based OO language such as C++, Java, Python, or contemporary JavaScript (ECMAScript 6 or higher).

This tutorial does not go into the history of prototype-based object-oriented programming. That history is complex and somewhat convoluted, and exploring it does little to enhance one's understanding of OOP with JavaScript. If you are interested, search the Web for “self programming language” and “prototype-based programming”.