Classical inheritance with protected members.

Basic classical inheritance with protected members and accessible overwritten methods.


Include Proclass in your application using strict mode (available on npm) and let the inheritance begin!

"use strict";

var Proclass = require("proclass");

var Foo = Proclass.extend({

    _init: function(baz){
        // Constructor function for class
        // Only available as constructor or within constructor of Class objects
        // that inherit from this (via `this._parent()`)

    somePublicFunction: function() {
        // Available to this class, Class objects that inherit from this,
        // and anywhere outside of this class

    _someProtectedFunction: function() {
        // Only available to this class and Class objects that inherit from this


var Bar = Foo.extend({

    somePublicFunction: function() {
        // Will overwrite `Foo.somePublicFunction()`
        // `Foo.somePublicFunction()` still accessible via `this._parent()`


var bar = new Bar(baz);


John Resig's Simple JavaScript Inheritance was a huge inspiration to this project. After trying several different approaches, I kept coming back to using a method very similar to his. (And I learned quite a bit because of it.) So, thanks!

Also, prodecjs gave me hope that protected members were indeed possible in JavaScript, and helped me with the basic implementation. Thanks!