// filterProperty i.e. 'id' or 'name'
function GetUniqueItems(array, filterProperty) {
return array
.map(e => e['filterProperty'])
.map((e, i, final) => final.indexOf(e) === i && i)
.filter(obj=> array[obj])
.map(e => array[e]);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter