DEV Community

Discussion on: The Six Functions That Will Ace Your VueJs Projects

Collapse
 
aarone4 profile image
Aaron Reese

In the array to object, if one of your array items is an object then I believe the nested object will only be a pointer to the original object. If you need a brand new copy then you will need to spread the value using acc.push(...cur.value)
If the new object contains its own nested objects, even in the new object these will be pointers to the originals. Deep (recursive) cloning is difficult and expensive. The lodash library has deep cloning functions