[removed] Remove duplicates of objects sharing same property value

后端 未结 12 1487
执念已碎
执念已碎 2020-11-30 06:00

I have an array of objects that I would like to trim down based on a specific key:value pair. I want to create an array that includes only one object per this s

12条回答
  •  时光说笑
    2020-11-30 06:12

    using lodash you can filter it out easily

    the first parameter will be your array and second will be your field with duplicates

    _.uniqBy(arrayWithDuplicates, 'color')
    

    it will return an array with unique value

提交回复
热议问题