I have an array like so:
var myarray = [
{"scaleId":"001","currentWeight":0.200}
{"scaleId":"002","currentWeight":0.300},
{"scaleId":"001","currentWeight":0.255},
{"scaleId":"002","currentWeight":0.000},
{"scaleId":"003","currentWeight":0.340},
]
and I want to retain the objects which have unique scaleId. So, for the above example, the output would like ( any random object can be retained if the scaleId is duplicate):
myarray = [
{"scaleId":"001","currentWeight":0.200}
{"scaleId":"002","currentWeight":0.300},
{"scaleId":"003","currentWeight":0.340},
]
I'm already using underscore library in my application, so I'm fine with the implementation using underscore. I had come up with a solution but it is not working as expected. So, any help will be great.