Reputation: 493
I have this:
nominees: Array<{ id: number, title: string, company: string, category: string }>;
I want to delete based on id, e.g. if the given id is 10, then I want to delete the element with the id of 10
I've been looking at splice, but honestly I'm really having a hard time. I'm quite new to Typescript
Upvotes: 0
Views: 293
Reputation: 341
If you don't want to use splice, you can use filter as below:
let result = nominees.filter(n => n.id !== 10);
Upvotes: 2