I am trying to remove an object from an array.So that I used splice
but before splice I made a copy of an object
this.program.lstProgramdetails.forEach((lph: any) => {
this.rtGridUp = Object.assign({}, lph);
this.rtGridMid = Object.assign({}, lph);
this.rtGridDown = Object.assign({}, lph);
lph.Details.forEach((inm: any, index: number) => {
if (inm.Track !== null && inm.Track.TrackDateIn !== null) {
this.rtGridMid.Details.splice(index, 1);
this.rtGridDown.Details.splice(index, 1);
} else if (inm.Track === null) {
this.rtGridUp.Details.splice(index, 1);
this.rtGridDown.Details.splice(index, 1);
} else {
this.rtGridUp.Details.splice(index, 1);
this.rtGridMid.Details.splice(index, 1);
}
});
});
based on the condition two of the arrays should be sliced and one should get object without splicing.
But watching in console it clears all the 3 arrays. Is there any possible way to splice that object without affecting the copy object?