Which fix removes the bug?
const copy = { ...settings };
copy.theme.color = 'red';
- Clone
themeseparately too - Use
Object.assigninstead - Freeze
settingsbeforehand - Spread
settingsa second time
Spread copies one level, so
Play Problem Solving ▸
copy.theme is still the original nested object.