Skip to content

Instantly share code, notes, and snippets.

@royriojas
Created September 16, 2012 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save royriojas/3730684 to your computer and use it in GitHub Desktop.
Save royriojas/3730684 to your computer and use it in GitHub Desktop.
OOP in javascript
;(function($) {
'use strict';
var Nexus = function() {};
Object._extend = function(child, parent) {
var base = Nexus.prototype = parent.prototype;
child.prototype = new Nexus();
var cp = child.prototype;
cp.constructor = child;
cp._super = base;
child._parent = parent;
};
Object._class = function (ctrFn, methods, baseClass) {
if (baseClass) {
Object._extend(ctrFn, baseClass);
}
$.extend(ctrFn.prototype, methods);
return ctrFn;
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment