What is the difference between shallow copy and deep copy of an object?

JavaScript Developer Medium

JavaScript Developer — Medium

What is the difference between shallow copy and deep copy of an object?

Key points

  • Shallow copy shares nested objects by reference
  • Deep copy duplicates all levels recursively
  • Shallow copy is not suitable for deep nested objects

Ready to go further?

Related questions