我有这个:
nominees: Array<{ id: number, title: string, company: string, category: string }>;
我想根据ID删除,例如如果给定的id为10,那么我想删除ID为10的元素
我一直在寻找接头,但老实说,我真的很难受。我对Typescript很陌生
答案 0 :(得分:2)
如果不想使用接头,则可以使用以下过滤器:
let result = nominees.filter(n => n.id !== 10);