How to create a new instance of an object to other var?

I have this object XXX and i need to create a new var of his type, i tried using: = Type.createInstance(XXX, []);

I just need somehow to create a new instance of this XXX and assign it to this other var, how can i do it?

Should the new instance have the same property values as XXX?

Reflect.copy might work in that case…

but as I understand it, It doesn’t make deep copies. so YYY.position would be a new Object, but YYY.position.x would reference the same value as XXX.position.x

I don’t really trust anything that isn’t explicitly declaring a new Object and assigning the values I want.

If you just need to make a new instance of the same type… maybe this would be ok
Type.createInstance(Type.getClass(XXX), []);

1 Like

Thanks brooo that’s what i was missing the Type.getClass(XXX), really thanks!