1//Remove an object from an array by ID (or by other parameter)
2person: Person = { id: 2, name: 'Maria' };
3listOfPersons = [
4 { id: 1, name: 'Jonas' },
5 { id: 2, name: 'Maria' }
6];
7
8removePerson(person: Person): void {
9 this.listOfPersons = this.listOfPersons.filter(({ id }) => id !== person.id);
10}