DEV Community

Discussion on: What's the best way to deeply clone an object in JavaScript?

Collapse
 
kevindsteeleii profile image
Kevin Steele

let obj = {stuff: {
more_stuff: "this",
list: [1,2,3]},
}

JSON.parse(JSON.stringify(obj))

Collapse
 
jasterix profile image
Jasterix

This is only a shallow clone so nested reference types would not be cloned