Skip to content

Instantly share code, notes, and snippets.

@karantir
Created October 10, 2013 19:39
Show Gist options
  • Save karantir/6924262 to your computer and use it in GitHub Desktop.
Save karantir/6924262 to your computer and use it in GitHub Desktop.
Function.prototype.inheritsFrom = function( parentClassOrObject ){
if ( parentClassOrObject.constructor == Function )
{
//Normal Inheritance
this.prototype = new parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject.prototype;
}
else
{
//Pure Virtual Inheritance
this.prototype = parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject;
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment