Let's say I have class called Person, which have firstName, lastName, and Array of addresses fields.
And in one of my angular components I am getting Person object to do some operation on them. But I would like to create two copies of this obj. To do that I am using Object.assign. But after that when I am manipulating firstName from firstCopyPerson all other objects are changed too.
How can I assign object to new variable without making reference to orginal object, but instead just creating new separate object?
mainPerson: Person;
firstCopyPerson: Person;
secondCopyPerson: Person;
ngOnInit() {
    this.mainPerson = someCache.getPerson(); 
    this.firstCopyPerson: Object.assign({}, this.mainPerson);
    this.secondCopyPerson: Object.assign({}, this.mainPerson);
}
 
     
     
     
    