Skip to content

Instantly share code, notes, and snippets.

@ischenkodv
Created August 22, 2010 00:35
Show Gist options
  • Save ischenkodv/543092 to your computer and use it in GitHub Desktop.
Save ischenkodv/543092 to your computer and use it in GitHub Desktop.
Function.prototype.inherits = function(fnParent) {
this.prototype.super = fnParent;
for (var s in fnParent.prototype) {
this.prototype[s] = fnParent.prototype[s];
}
return this;
}
parentClass = function (args) {
this._name = '';
this.__defineGetter__("name", function(){
return this._name;
});
this.__defineSetter__("name", function(val){
this._name = val.replace('t','p');
return;
});
}
childClass = function (args) {
this.super(args); //constructor for super
}.inherits( parentClass );
var test = new childClass( );
test.name = 'test';
alert( test.name ); //returns pest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment