public oldClient: Client = new Client();
public client: Client = new Client();
private clientId: string = "xxx";
this.userService.getClient(this.clientId).subscribe((data: Client) => {
this.client = data;
this.oldClient = data;
this.client.name = "test";
console.log(this.client.name) // Output : "test"
console.log(this.oldClient.name) // Output : "test"
});
Why when im changing a property from my variable "client" this will impact "oldCLient" and how can I prevent this ? Thanks.