Using Object.assign to add properties to an object

Combining the properties from different objects is a fairly common task. Doing this value by value is limited and tedious, because each property has to be enumerated. This recipe demonstrates how to do the same thing with the Object.assign method.

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.