/** * Foo Object */ var Foo = function (config) { var options = JSON.parse( JSON.stringify(config) ); options.items = []; _.extend(this, options); }; Foo.prototype.set = function (config) { _.extend(this, config); return this; }; Foo.prototype.addItem = function (items) { items = _(items).isArray() ? items : [items]; this.items = _.union(this.items, items); return this; };