I don't know well but seems here have a good explanation of how you could do it
When reading, the one you used is the fast cloning, take a look at here (the third one maybe) : https://stackoverflow.com/a/122704
There is also this article: https://www.samanthaming.com/tidbits/70-3-ways-to-clone-objects/
And this one from MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign