I have a Dynamic object from Json and need to clone that in Haxe. Is there any easy way to clone object, please let me know. Or if it's impossible, I want at least iterate that Dynamic object such as JavaScript object.
var config = {
loop : true,
autoplay : true,
path : "data.txt"
};
var newConfig = {};
for (i in config) {
if (config.hasOwnProperty(i))
newConfig[i] = config[i];
}
Use Reflect.copy()
:
var newConfig = Reflect.copy(config);
Note that it only guaranteed to work on anonymous structures. For other objects, use the appropriate Reflect
methods.
var newConfig = Reflect.copy(config)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With