Assignment copies the object reference value. An object spread copies own enumerable properties into a new outer object, but nested object values still reference the same objects. For an immutable update, copy each object along the changed path. structuredClone can deeply copy many data types, but it cannot clone functions.
Follow-up Interview Question · When is sharing the untouched branches desirable?