Which fix removes the bug?
const copy = { ...original };
copy.address.city = 'Riyadh';
- Clone nested objects too
- Freeze the original first
- Use Object.assign instead
- Declare copy with
let
Spread is shallow, so
Play Problem Solving ▸
address is still the same object the original references.