Skip to content

Instantly share code, notes, and snippets.

@alexdibattista
Created August 22, 2014 19:28
Show Gist options
  • Save alexdibattista/1ee249f9b2eee7a6666a to your computer and use it in GitHub Desktop.
Save alexdibattista/1ee249f9b2eee7a6666a to your computer and use it in GitHub Desktop.
MyBaseClass = function(a) {
this.a = a;
};
MyBaseClass.prototype.filter = function(){
console.log('I am initializing the base class');
};
MyChildClass = function(a){
this.a = a;
};
MyChildClass.prototype = Object.create(MyBaseClass.prototype);
MyChildClass.prototype.filter = function(){
MyBaseClass.prototype.filter.call(this);
console.log('I am initializing the child class');
};
MyChildClass2 = function(a){
this.a = a;
};
MyChildClass2.prototype = Object.create(MyBaseClass.prototype);
MyChildClass2.prototype.filter = function(){
MyBaseClass.prototype.filter.call(this);
console.log('I am initializing the child class2');
};
var child = new MyChildClass();
console.log(child);
var child2 = new MyChildClass2();
console.log(child2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment