shallow copy and deep coyp in javascript and angular
shallow copy and deep coyp in javascript and angular
Shallow Copy
and Deep Copy
in Angular (and
JavaScript)
SWIPE
Shallow Copy:
A shallow copy replicates an object's top-level
properties, but nested objects or arrays remain
references to the original.
Deep Copy:
A deep copy creates a complete independent
clone of the original object, including nested
objects.
Key Notes on Shallow and Deep Copy:
Object.assign({}, obj)
Spread operator (...).
Array slice() or concat(): Creates shallow
copies of arrays.