Skip to content

Instantly share code, notes, and snippets.

@ijse
Created May 25, 2012 03:02
Show Gist options
  • Save ijse/2785497 to your computer and use it in GitHub Desktop.
Save ijse/2785497 to your computer and use it in GitHub Desktop.
JS:extend function based on Prototype
/**
* Function Extend based on Prototype
* @author ijse
*/
exports.extend = function(sub, superclass) {
var F = function() {};
F.prototype = superclass.prototype;
sub.prototype = new F();
sub.prototype.constructor = sub;
sub.superclass = superclass.prototype;
superclass.prototype.constructor = superclass;
return sub;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment