Created
April 3, 2014 09:03
-
-
Save telekosmos/9951006 to your computer and use it in GitHub Desktop.
Module pattern along with prototypal inheritance...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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