Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.