Consider this scenario: Suppose we have an object with the following properties:
const objOne = {
car: 'ford',
location: 'Munich',
driver: 'John'
}
and a second object that only contains some of the properties from the first object:
const objTwo = {
car: 'BMW',
driver: 'Marta'
}
Is there a way to merge the properties from the second object into the first object without losing the properties of the first object, such as location: 'Munich'
? I am aware of the Object.assign
method, but it completely copies the target object, which is not what I want in this case.