Factory[name] = data[name]; Factory[name].prototype.data = function (name, value) { var constr = this.constructor; if (value !== undefined) constr[name] = value; return constr[name]; };