underscore/lodash unique by multiple properties

前端 未结 5 1818
天涯浪人
天涯浪人 2020-12-14 01:08

I have an array of objects with duplicates and I\'m trying to get a unique listing, where uniqueness is defined by a subset of the properties of the object. For example,

5条回答
  •  天涯浪人
    2020-12-14 01:46

    Here there's the correct answer

    javascript - lodash - create a unique list based on multiple attributes.

    FYI var result = _.uniqBy(list, v => [v.id, v.sequence].join());

提交回复
热议问题