How do you deep clone an array of objects "the old way." In other words, before the introduction of methods of modern, native methods like JSON.parse, assign, extend, or the spread operator.
The solution is for some Photoshop scripts. Adobe is still using JS v1.5 (or ECMAScript 3) - meaning any JS functionality since 2000 isn't native. Ideal solutions would deep clone but avoid Photoshop specific objects, such as "layers" (more on that at the end).
Alternatively, a lightweight library mocking modern functionality would work. I've already tried this JSON2 implementation but ran into the following error:
Error 8450: The operation is not valid for channels of type component.
I came across this JSON resource, but the guide seemed daunting, so I haven't gotten far yet.
The array of objects is currently structured like so:
object = [
{
prop: string,
array: [{layerObject},{layerObject}...]
},
{...},
]
Ideally all of the above except the 'layerObjects' would be cloned. The layerObjects should not be cloned because they are references to onscreen Photoshop elements that need to be tracked and manipulated.