I'd like to summarize status of the "spread object merge" ES feature, in browsers, and in the ecosystem via tools.
- https://github.com/tc39/proposal-object-rest-spread
- This language feature is a stage 4 proposal, which means it's been merged into the ES language spec, but not yet widely implemented.
- Browser support for "spread properties" shipped in Chrome 60, including this scenario.
- Support for this scenario does NOT work in current Firefox (59), but DOES work in my Firefox Developer Edition. So I believe it will ship in Firefox 60.
- Safari: not tested, but Kangax says it works in Desktop Safari 11.1, but not SF 11
- iOS Safari: not teseted, but Kangax says it works in iOS 11.3, but not in iOS 11
- not in Edge yet
- NodeJS has supported since 8.7 (via Kangax). Confirmed on 9.8 when I tested locally.
- TypeScript has suported it since 2.1, current is 2.8
var x = { a: 1, b: 2 };
var y = { c: 3, d: 4, a: 5 };
var z = {...x, ...y};
console.log(z); // { a: 5, b: 2, c: 3, d: 4 }
Again: At time of writing this sample works without transpilation in Chrome (60+), Firefox Developer Edition (preview of Firefox 60), and Node (8.7+).
I'm writing this 2.5 years after the original question. But I had the very same question, and this is where Google sent me. I am a slave to SO's mission to improve the long tail.
Since this is an expansion of "array spread" syntax I found it very hard to google, and difficult to find in compatibility tables. The closest I could find is Kangax "property spread", but that test doesn't have two spreads in the same expression (not a merge). Also, the name in the proposals/drafts/browser status pages all use "property spread", but it looks to me like that was a "first principal" the community arrived at after the proposals to use spread syntax for "object merge". (Which might explain why it is so hard to google.) So I document my finding here so others can view, update, and compile links about this specific feature. I hope it catches on. Please help spread the news of it landing in the spec and in browsers.
Lastly, I would have added this info as a comment, but I couldn't edit them without breaking the authors' original intent. Specifically, I can't edit @ChillyPenguin's comment without it losing his intent to correct @RichardSchulte. But years later Richard turned out to be right (in my opinion). So I write this answer instead, hoping it will gain traction on the old answers eventually (might take years, but that's what the long tail effect is all about, after all).