the alternative is that the second argument expects an array of 1 to n source objects. This works with reduce and leaves way clear for future 3rd argument (eg deep copy boolean)
On Tue, Dec 17, 2013 at 5:24 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > true ... as true is for anything that will ever be passed to reduce that > accept just 2 arguments. Handy in a way, blocking progress in others. > > `Object.assing(target, ...[multSources]);` > > wins to me > > > On Tue, Dec 17, 2013 at 5:20 PM, Domenic Denicola < > dome...@domenicdenicola.com> wrote: > >> Interestingly, if multiple arguments are not added now, they may never be >> possible, since there will be so much `[a, b, c].reduce(Object.assign)` >> code in the wild that implicitly passes an index as the third parameter and >> the whole array as the fourth parameter. >> >> -----Original Message----- >> From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of >> Brendan Eich >> Sent: Tuesday, December 17, 2013 20:18 >> To: Claude Pache >> Cc: es-discuss >> Subject: Re: Object.assign with several source objects >> >> It's now or never. I agree multiple sources are useful enough to do now; >> I don't see a different third parameter that would be precluded by deciding >> this. But others may disagree. >> >> /be >> >> > Claude Pache <mailto:claude.pa...@gmail.com> December 17, 2013 5:06 PM >> > Hello, >> > >> > Tonight, when playing with ES6's new functions, I was wishing that >> > `Object.assign` could accept several `source` objects: >> > >> > Object.assign(target, source1, source2, ...) // equivalent to >> > `Object.assign(Object.assign(Object.assign(target, source1), source2), >> > ...)` >> > >> > My use case: I have several objects, used as dictionaries, coming from >> > different sources, and I want to merge them together. For example: >> > >> > c.prototype.exec = function(userParams) { var params = Object.assign({ >> > method: "GET" }, this.defaultParams, >> > userParams) >> > // etc. >> > } >> > >> > Any thoughts? >> > >> > -Claude >> > _______________________________________________ >> > es-discuss mailing list >> > es-discuss@mozilla.org >> > https://mail.mozilla.org/listinfo/es-discuss >> > >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss