I have tried all the examples listed here, and no matter which one I take including the JSON parse / stringify, when I modify an element in the original array, it is automatically reflected in the backup as is the case in a copy by reference. I need to find a way to break the link and reliably back up by value.
this.backupPersons = JSON.parse(JSON.stringify(this.persons));
this.backupPersons = this.persons.slice(0);
this.backupPersons = this.persons.concat();
this.backupPersons.concat(this.persons);
this.backupPersons = angular.copy(this.persons);
for (var i in this.persons) {
this.backupPersons.concat(this.persons[i]);
}
this.persons.forEach(function (arrayItem) {
this.backupPersons.concat(arrayItem);
});
for (const element of this.persons) {
this.backupPersons.push(element);
}