Skip to content

Instantly share code, notes, and snippets.

@cccaldas
Created January 27, 2012 13:13
Show Gist options
  • Select an option

  • Save cccaldas/1688710 to your computer and use it in GitHub Desktop.

Select an option

Save cccaldas/1688710 to your computer and use it in GitHub Desktop.
js oop
//oop
Function.prototype.extends = function(parentClassOrObject){
if(parentClassOrObject.constructor == Function)
{
//normal inheritance
this.prototype = new parentClassOrObject;
this.prototype.constructor = this;
this.prototype.super = parentClassOrObject.prototype;
}
else
{
//pure virtual inheritance
this.prototype = parentClassOrObject;
this.prototype.constructor = this;
this.prototype.super = parentClassOrObject;
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment