Let assume we have data something like this arr=[{id:1,age:17},{id:2,age:19} ...]
, then we can find unique objects like this -
function getUniqueObjects(ObjectArray) {
let uniqueIds = new Set();
const list = [...new Set(ObjectArray.filter(obj => {
if (!uniqueIds.has(obj.id)) {
uniqueIds.add(obj.id);
return obj;
}
}))];
return list;
}
Check here Codepen Link