[RECIPE]: distinct operation for array
Being web full stack developer after years of .NET work sometimes brings you to a blind alley. For example, such trivial thing as `.distinct()` function for array, which is not present in TS/JS. So, let's find out how to do the same.
const data: ItemType[] = [{id: 1}, {id: 1}, {id: 2}];
const distinctItems = data.reduce((result: ItemType[], current: ItemType) => {
return result.some(x => x.id === current.id) ? result : result.concat([current]);
}, []);
Reduce has number of usages!