0
For what reason he put on answer 'baz' ? //Why not 'bar'.
const obj1 = { foo: 'bar', x: 42 }; const obj2 = { foo: 'baz', y: 5 }; const clonedObj = { ...obj1 }; // { foo: "bar", x: 42 } const mergedObj = { ...obj1, ...obj2 }; // { foo: "baz", x: 42, y: 5 }
3 Answers
+ 3
if your question was about mergedObj, 'baz' overide 'bar' coz left to right precedence (first arg is firstly destructuring, then second...)
0
to better distinguish obj1 from obj2 ^^
0
visph ok thank u