Hi Tod Gentille, thanks so much for stopping by with the useful example! This is a great little bit of TypeScript code you shared:
If I’m understanding this correctly, this will only deep copy the first layer, but it does not recurse to any more-deeply nested objects or array.
I’m sure it would not take much more code to use
.slice() recursively to deep copy an array, though.
I love the clarity of the example, combining
.slice() like that.
Well done, and thanks for sharing!