I understand that given an array of objects, I can use _.uniq()
to filter out the unique objects by checking against an object property common to each object. I’m wondering, can I check against two properties at once?
For example:
var foo = [
{"name":"Steve", "age":"56", "car":"Porsche"},
{"name":"Steve", "age":"56", "car":"Mercedes"},
{"name":"Bill", "age":"57", "car":"Porsche"},
{"name":"Linus", "age":"56", "car":"Mercedes"}
];
var bar = _.unique(foo, false, function(obj, k, v){
return obj.name && obj.age;
});
console.log(bar);
I was quite hoping I’d get back Steve, Bill and Linus. However, it looks as though only obj.age
is being checked against.