Shallow vs Deep Copy

Back to Prototype

Shallow copy duplicates the top-level object but shares references to nested objects. Deep copy recursively duplicates all nested objects, creating a fully independent clone. The choice affects correctness and performance.

property prototype copy