DEV Community

Discussion on: JavaScript Interviews: Create a deep copy of an object

Collapse
 
ninofiliu profile image
Nino Filiu

Object.assign is equivalent to object spread and only copies the top level keys of an object

const a = { b: { c: 10 } }
const clonedA = { ...a }
clonedA.b.c++
a.b.c // 11
Enter fullscreen mode Exit fullscreen mode