DEV Community

Discussion on: If you Wannabe (assigned) in my JS Object: Conditionally adding properties to JS Objects

Collapse
 
silvestricodes profile image
Jonathan Silvestri

Good question! Object.assign does not duplicate the target object in memory - it adds on to the existing object, and in the case of clashing keys, the keys and their values from the added object will overwrite the existing one.

With that being the case, the same answer applies to the spread operator.