Spread Operator: Shallow Copy

In shallow copy, an object is copied and the main object reference changes, and the child or child of child object references do not change. The spread operator does a shallow copy

In the case of the nested objects, shallow copy makes code complicated but still, it is efficient.

Deep Copy

Helps in copying deep by creating new references for all the child objects. Libraries like lodash help to easily perform a deep copy.

But deep copy affects the performance.

Deep Copy Problems/ Disadvantages

About the Author: smartcoder

You might like

Leave a Reply

Your email address will not be published. Required fields are marked *