Skip to content

Instantly share code, notes, and snippets.

@anthonybrown
Created June 25, 2012 22:56
Show Gist options
  • Save anthonybrown/2991986 to your computer and use it in GitHub Desktop.
Save anthonybrown/2991986 to your computer and use it in GitHub Desktop.
Custom Class library
var Class = function(parent){
var klass = function(){
this.init.apply(this, arguments);
};
// Change klass' prototype
if (parent) {
var subclass = function() { };
subclass.prototype = parent.prototype;
klass.prototype = new subclass;
};
klass.prototype.init = function(){};
// Shortcuts
klass.fn = klass.prototype;
klass.fn.parent = klass;
klass._super = klass.__proto__;
/* include/extend code... */
return klass;
};
@anthonybrown
Copy link
Author

Custom javascript library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment