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 }

8th Mar 2021, 12:10 AM
Noname
Noname - avatar
3 Answers
+ 3
if your question was about mergedObj, 'baz' overide 'bar' coz left to right precedence (first arg is firstly destructuring, then second...)
8th Mar 2021, 12:14 AM
visph
visph - avatar
0
to better distinguish obj1 from obj2 ^^
8th Mar 2021, 12:12 AM
visph
visph - avatar
0
visph ok thank u
8th Mar 2021, 12:16 AM
Noname
Noname - avatar