Did you know that JavaScript now has a native way to do deep copies of objects? Thanks to the structuredClone function built into the JavaScript runtime, we can easily copy objects, nested arrays, and even Date objects. This function can clone infinitely nested objects and arrays, handle circular references, and clone various JavaScript types like Date, Set, Map, and more. It even supports transferring transferable objects. Unlike other methods like object spread or JSON.parse(JSON.stringify()), structuredClone ensures a complete deep copy of objects without any shared references. So why not give it a try?
https://www.builder.io/blog/structured-clone