Implement a deep clone. Handle nested objects/arrays and circular references.
Recursion over unknown structure, and awareness of edge cases (circularity, Date, Map).
Recurse: for objects/arrays, create a new container and clone each value. Guard circular references with a WeakMap of already-cloned sources. Mention structuredClone() as the modern built-in (handles Dates, Maps, Sets, circular refs) — knowing when NOT to hand-roll is senior signal. JSON.parse(JSON.stringify(x)) is the naive answer but drops functions, undefined, and Dates, and throws on cycles. The WeakMap is doing two jobs: correctness (a node that appears twice in the graph is cloned once and shared, preserving identity) and termination (without it, a cycle recurses forever). Edge cases a thorough answer names: preserve the prototype with Object.create(Object.getPrototypeOf(value)) if you care about class instances; handle Map/Set/RegExp/typed arrays explicitly; and note that structuredClone still can't clone functions, DOM nodes, or prototype chains — so for React/Redux state the pragmatic choice is often shallow copies at each changed level (spread) rather than a full deep clone.
Cloning state before mutation (Redux/immutability), snapshotting config. Prefer structuredClone or a library in production.