I have an array which contains arrays of objects. I want to get the unique property values from the array. E.g.
var array = [
[
{
a: 'ggg'
},
{
a: 'kkk'
}
],
[
{
a: undefined
}
],
[
{
a: 'ddd'
}
],
[
{
a: 'ggg'
}
]
];
Would return:
['ggg', 'kkk', 'ddd']
Im using the underscore library, heres what I tried:
var list = _.reduce(arr, function(memo, v, k) {
memo.concat(_.pluck(v, 'a'));
return memo;
}, []);
console.log('list is ', list);
console.log(_.uniq(list));
But its not working. The fiddle is here.