Object.assign vs spread Playground

Mr. Yusuf’s record merges with a change form at the counter through Object.assign and spread: which object changes, which drawer wins, and what becomes of the…

Why it matters

Merging objects is everywhere: updating React state, overriding default settings, applying a patch. Pick wrong and state is mutated silently (React does not re-render), or "why did the original change" because a box inside is shared.

The key idea

The only difference is the target: data itself, or a new object. Both are shallow.

Common mistakes

Try it in this playground