Using a spread operator to combine objects

In a previous recipe, we saw how to use Object.assign to combine objects. It gets the job done, but by using newer ECMAScript syntax we can do this in a more compact way. In this recipe, we'll see how to use the new spread operator to combine objects.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.