Skip to content

Latest commit

 

History

History
20 lines (12 loc) · 1.13 KB

README.md

File metadata and controls

20 lines (12 loc) · 1.13 KB

Learning Resources

Shallow vs Deep Copy

Shallow Copy Deep Copy
Original and shallow copy both point to the same memory location Original and deep copy point to different memory locations
Use ... spread operator:
let shallowCopy = {...original}
Use JSON:
let deepCopy = JSON.parse(JSON.stringify(original))
Use Object.assign():
let shallowCopy = Object.assign({}, original)