JavaScript Deep copy for array and object
Gamshan Vigneswaran
7298

I found Array.from(myObject, obj => Object.assign({}, obj)) to be a faster solution for an array of objects in my project where I was using the JSON.parse(JSON.stringify()) method.

I’m checking for changes in an array of objects and need to make a copy of this before any potential changes can occur to check if changes actually happened or not for use in a dashboard move/resize events.

Hope this helps!

https://jsperf.com/deep-clone-array-from-vs-json-parse