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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Does using the spread
{..._}
operator orObject.assign()
duplicate the object in memory instead of simply extending the existing one?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.