JSFiddle - React, Tailwind, and code Playground

HTML

<p>
Object.assign(obj1, obj2); may be the preferable way as let merged = {...obj1, ...obj2}; creates a new object and copies the the properties of obj1 and obj2 into it 
</p>

<b>for see difference just open console & run program</b>

<ul>
<li>for more info about <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign">Object.assign()</a></li>

<li>for more info about <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#spread_in_object_literals">Spread in object literals</a></li>
</ul>

JavaScript

const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };

const returnedTarget = Object.assign(target, source);

console.log(target);
// Expected output: Object { a: 1, b: 4, c: 5 }

console.log(returnedTarget === target);
// Expected output: true

const target2 = { a: 1, b: 2 };
const source2 = { b: 4, c: 5 };
const mergedObjUsingSpreadSyntax = { ...target2, ...source2 };

console.log(target2);
// Expected output: Object { a: 1, b: 2 }
console.log(mergedObjUsingSpreadSyntax);
// Expected output: Object { a: 1, b: 4, c: 5 }
console.log(mergedObjUsingSpreadSyntax === target);
// Expected output: true