I have this array:
dataArr: DataCode = [dataObj1, dataObj2, dataObj3, dataObj4, ... ]
And array of id:
idArray:string=["3","5","2","8","4"];
Here is the defenition of DataCode:
export interface DataCode {
userId: string;
codeName: string;
id: string
}
How can I get from array dataArr all objects that has id value as in idArray.
idArray.map(id => dataArr.filter(d=>d.id === id))- that will give you a nested array of matches for each id in youridArrayidArray.map()where the callback does either afilteror afindagainstdataArr, but without concrete and valid data it's hard to tell.