Skip to content

Instantly share code, notes, and snippets.

@sap1ens
Created April 24, 2012 16:11
Show Gist options
  • Save sap1ens/2481077 to your computer and use it in GitHub Desktop.
Save sap1ens/2481077 to your computer and use it in GitHub Desktop.
Truly JavaScript inheritance
function extend(subClass, superClass) {
var F = function() {};
F.prototype = superClass.prototype;
subClass.prototype = new F();
subClass.prototype.constructor = subClass;
subClass.superclass = superClass.prototype;
if(superClass.prototype.constructor == Object.prototype.constructor) {
superClass.prototype.constructor = superClass;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment