Skip to content

Instantly share code, notes, and snippets.

@flarnie
Created August 22, 2013 15:47
Show Gist options
  • Select an option

  • Save flarnie/6308973 to your computer and use it in GitHub Desktop.

Select an option

Save flarnie/6308973 to your computer and use it in GitHub Desktop.
A helper function to get a target class to inherit from another class without side-effecting the parent class prototype.
Function.prototype.inherits = function(parent){
function Surrogate(){};
Surrogate.prototype = parent.prototype;
this.prototype = new Surrogate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment