I'm trying to copy data from one array to another for manipulation.
Below is the code
let data=[];
this.dataArray.length=0;
this.dataArray=[];
for(var i=0;i<this.test.length;i++){
data.push(this.test[i]);
}
data.forEach((element)=>{
let Config=element.config;
Config.forEach((config)=>{
let obj=this.formatMap(config.Map,config.operation);
delete config.Map;
config["Map"]=obj;
})
delete element.isExpand
delete element.name
})
console.log(data);
console.log(this.test);
Basically in the original array Map is an array , and in the data array I want it to be an object to send it to the api.
The original array is also getting modified.
I know we can use spread operator also but my tslib is not updated and hence I can't do that.
I have also used splice operator to create the data array for the test array. console log for both the array shows that the original array is also getting modified,
Below is the error in console which confirms that the original array is also getting modified.
Error: Error trying to diff '[object Object]'. Only arrays and iterables are allowed
Please Guide. Thanks