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 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
Object-oriented programming traditionally relies on classes and their instantiations. JavaScript supports object-oriented programming, but it does so by means of constructor functions and prototypes rather than classes. The purpose of this tutorial is to explain the JavaScript way of supporting OOP to people who are accustomed to the traditional class-based style.

A working knowledge of JavaScript and familiarity with a traditional, class-based OO language such as C++, Java, or Python.

Why This Tutorial
Given the immense popularity of the JavaScript language, it shouldn't come as a surprise that the information contained in this tutorial is already out there in many variations. What seems to be lacking is a recipe-style presentation for people who are accustomed to OOP with classes and their instantiations, showing them how to transition to OOP with JavaScript's constructor functions and prototypes.

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”.