Optimized pulling items out of arrays in nested objects
Although at the time of writing, flatMap is not in every browser (according to MDN not in Edge and Samsung Internet);

data.flatMap(obj =&gt; obj.items).filter((e, i, ary) =&gt; ary.indexOf(e) == i)


Although, you could check the uniqueness from the result array in your code, and push only if not in there, to save one loop over the array.

Another option would be a reducer like

uniqItems = (acc, {items}) =&gt; acc.concat(items.filter(item =&gt; acc.indexOf(item) &lt; 0))


to data.reduce(uniqItems, []).