Where this matters
Copying settings with spread separates the outer record, but nested settings still need attention when you want independent edits.
const original = { settings: { theme: 'light' } };
const copy = { ...original };
copy.settings.theme = 'dark';
console.log(original.settings.theme);Read the full explanation
Spread copies the outer object. Both settings properties still reference the same nested object, whose theme is changed.
Trace the code
- The outer copy is a different object from original.
- The settings reference is copied as a property value; the nested object itself is not copied.
- Both paths reach that nested object, so changing its theme is visible through original.
Why the other predictions differ
light— A shallow spread does not duplicate nested objects.undefined— The settings property exists on both outer objects.
dark
Reading this explanation does not record mastery. A correct submitted attempt can do so, including after review.
Change one thing
Copy the settings object as well, then change the copied theme.
Predict the result, then run this self-contained snippet in your browser’s developer console. It uses only sample values and makes no network requests.
const original = { settings: { theme: 'light' } }; const copy = { ...original, settings: { ...original.settings } }; copy.settings.theme = 'dark'; console.log(original.settings.theme);Check the variation’s output
light
Explain which binding, value, or operation changed before moving to the next challenge.