## Shallow Copy
Happens when only copy reference.
```javascript
const a = {"k": "v"};
const b = a; // here, b copies the reference of a
```
Top-level properties are copied, but nested objects/arrays still reference the original memory location.
## Deep Copy
Can use `JSON.parse(JSON.stringify())` to create a deep copy.
Can also use the spread operator `{ ... }`.
Can also use `lodash` library.
### Limitations
- Only works for serializable data
- Loses circular references
- Date objects are lost
## References
- [[JavaScript Study MOC]]
- [Shallow Copy and Deep Copy in JavaScript - Geeks for Geeks](https://www.geeksforgeeks.org/javascript/what-is-shallow-copy-and-deep-copy-in-javascript/)