I have an object array:
var objects = [
{'key1': '1', 'key2': '2'},
{'key1': '3'},
{'key1': '4', 'key2': '5', 'key3': '6'},
{'key1': '1', 'key2': '2'},
{'key1': '3'},
{'key1': '4', 'key2': '5', 'key3': '6'},
];
I want an array with unique values of key2
but without any undefined
values in it. Something like this:
['2', '5']
Right now, I'm using:
lodash.without(lodash.uniq(lodash.map(objects, 'key2')), undefined)
My Question:
Is there a better and more compact way to do this?