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
@xk oooops, true. I didn't notice... -_-
@xk @polotek, so basically you both get rid of the closure (actually makes sense) and have taken a similar approach. Thank you.