Skip to content

Instantly share code, notes, and snippets.

@polotek
Forked from doup/Instanciating
Created December 9, 2010 14:51
Show Gist options
  • Save polotek/734781 to your computer and use it in GitHub Desktop.
Save polotek/734781 to your computer and use it in GitHub Desktop.
var Base = {
_ops: {},
_privateFnc: function () {},
abstract: function () {},
init: function (ops) {
this._ops = ops || {};
// INIT
}
};
var ThingBaseProps = {
abstract: {
value: function() {
return this._ops;
}
}
};
var ThingBase = Object.create(Base, ThingBaseProps);
var Thing = 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