I'm trying to filter an array of class objects which have again class objects nested in it. I know it is confusing, I'll provide a sample code:
//class
export class Class1{
id:number;
team: Teams // here another class contains 'id' and 'name'
}
// Assume that the variable this.tmpObj contains array of Class1 objects
tmpObj:Class1[];
So here I want to take only the Class1 objects not having team.id 100.
this.tmpObj= this.tmpObj.filter(({ team }) => {
return team.id != 100
})
But this code shows error that team.id is null.I tried some other ways of filtering. But same error. Any idea what was the error. Thanks in advance.