Skip to content

Instantly share code, notes, and snippets.

@telekosmos
Created April 3, 2014 09:03
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 telekosmos/9951006 to your computer and use it in GitHub Desktop.
Save telekosmos/9951006 to your computer and use it in GitHub Desktop.
Module pattern along with prototypal inheritance...
namespace('MINE');
MINE.parent = (function() {
// private funcs and vars here
// Public API - constructor
var Parent = function (coords) {
// ...do constructor stuff here
};
// Public API - prototype
Parent.prototype = {
constructor: Parent,
func1: function () { ... },
func2: function () { ... }
}
return Parent;
}());
MINE.child = (function () {
var Child = function (coords) {
Parent.call(this, arguments);
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
Child.prototype.func2 = function () { ... };
return Child;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment