extract data from object when it match with array of ids js

Solutions on MaxInterview for extract data from object when it match with array of ids js by the best coders in the world

showing results for - "extract data from object when it match with array of ids js"
Mélissa
30 Sep 2016
1 const keep = new Set(['id4', 'id2']);
2
3 const result = [];
4
5 for(const items of Object.values(data.items))
6   for(const item of items)
7     if(keep.has(item.id))
8       result.push(item);