Skip to content

Instantly share code, notes, and snippets.

@leodutra
Last active Aug 29, 2015
Embed
What would you like to do?
JavaScript simple inheritance.
function EXTENDS(super_, extension) {
var obj = function() {};
var proto = obj.prototype = new super_();
proto.super = function() {
super_.apply(this, arguments);
};
for (var prop in extension) {
if (extension.hasOwnProperty(prop)) proto[prop] = extension[prop];
}
return new obj();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment