I have the an array, listPeople
and to eliminate duplicates I use the following code in ES6:
var listPeople = [{
"nomCustomer": "Fran",
"attrName": "aaa"
},
{
"nomCustomer": "John",
"attrName": "ccc"
},
{
"nomCustomer": "Paul",
"attrName": "ddd"
},
{
"nomCustomer": "Paul",
"attrName": "ddd"
}
];
var list = listPeople.reduce((unique, o) => {
if (!unique.some(obj => obj.nomCustomer === o.nomCustomer && obj.attrName === o.attrName)) {
unique.push(o);
}
return unique;
}, []);
console.log(list)
What would it be like for ES5?