Recently, I had to implement a clone button at work.
Unfortunately, the copied item had a attribute
items that was a list.
Whenever the cloned item changed or the original item changed, they
both were updating. This is common problem in both Python and JS.
above - reference issue with cloned items
underscore.js only has a shallow copy
The solution is easier than I thought it was going to be:
That’s it! A hacky well supported way to deep copy.