Given an array of objects like the one below:
var items = [
{item: [{foo: 21, bar: 'a' }, {foo: 5,bar: 'e'},{foo: 167, bar: 'c'}]},
{item: [{foo: 42, bar: 'a' }, {foo: 45,bar: 'd'},{foo: 7, bar: 'c'}]},
{item: [{foo: 99, bar: 'b' }, {foo: 35,bar: 'c'},{foo: 22, bar: 'e'}]},
{item: [{foo: 31, bar: 'e' }, {foo: 22,bar: 'd'},{foo: 12, bar: 'a'}]}
]
I want to create a new array that contains all unique values of the 'bar' property. So, it should look something like this:
var uniqueBars = ['a','b','c','d','e'];
Currently, my solution involves looping through all the items, but I believe there might be a more efficient way to achieve this using ES6 features.
Is there a way to generate the uniqueBars array mentioned above using ES6 functionalities?