// filterProperty i.e. 'id' or 'name'
function GetDuplicates(array, filterProperty) {
//lookup with our intended filter to get the duplicates by a given property
const lookup = array.reduce((a, e) => {
a[e.filterProperty] = ++a[e.filterProperty] || 0;
return a;
}, {});
let duplicates = array.filter(e => lookup[e.filterProperty]);
return duplicates;
}