Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created September 16, 2012 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnhunter/3732991 to your computer and use it in GitHub Desktop.
Save johnhunter/3732991 to your computer and use it in GitHub Desktop.
Nice implementation of Crockford's beget / object.create
/**
* Nice implementation of Crockford's beget / object.create
* @param {Function} base - the base constructor
* @return undefined
* example: Dog.inherit(Animal);
*/
Function.prototype.inherit = function (base) {
function Inheriter() { }
Inheriter.prototype = base.prototype;
this.prototype = new Inheriter();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment