Comment
Greg42
Mega Guru
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
07-27-2018
07:37 AM
Ha! I am a big advocate of using built-in objects and methods. I think sooner or later most of us find a need to implement this solution.
This was my take on it, hope it helps:
function uniqueObjectList(objArray, prop) {
return objArray.filter(function(filterObj, pos, thisArray){
return thisArray.map(function(mapObj){
return mapObj[prop];
})
.indexOf(filterObj[prop]) === pos;
});
}