Created
July 25, 2010 20:04
-
-
Save doup/489840 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var Base = { | |
_ops: {}, | |
_privateFnc: function () {}, | |
abstract: function () {}, | |
init: function (ops) { | |
this._ops = ops || {}; | |
// INIT | |
} | |
}; | |
var Thing = (function () { | |
var ThingBase = Object.create(Base); | |
ThingBase = { | |
abstract: function() { | |
return this._ops; | |
} | |
}; | |
return function (ops) { | |
var instance = Object.create(ThingBase); | |
instance.init(ops); | |
return instance; | |
}; | |
})(); | |
var thingA = Thing(), | |
thingB = Thing({foo:'bar'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Re-arranged things a bit to cut down on object creation and get rid of the unnecessary closure. Of course I didn't test that at all :)
https://gist.github.com/734781