myObj : [] = [];
tmpObj: [] = [];
ngOnInit() {
this.myService.getData().subscribe(
data => {
this.myObj = data.values;
this.tmpObj = Object.assign([], this.myObj);
}
)
}
updateData(prop, val) {
this.myObj[prop] = val;
}
When I call updateData method and update the property of myObj, this change affect the tmpObj. But I don't want the tmObj object to be affected by these changes. What am I supposed to do for this?