I have a json array like this :
myArray=[{ a:1,
b:[{c:"x",d:"y"}, {c:"r", d:"s"}...]
},
{ a:2,
b:[c:"p",d:"q"}, {c:"x", d:"s"}...]
}
...
]
Is it possible to get a subset of myArray with unique values of "c" using underscore.js?
This should do it:
_.chain(myArray)
.pluck("b")
.flatten()
.pluck("c")
.unique()
.value()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With