lodash好用系列- json数组,根据指定key去重

Posted 哈娄

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lodash好用系列- json数组,根据指定key去重相关的知识,希望对你有一定的参考价值。

import  uniqBy  from 'lodash'



let arr2 = [  x: 1, y: 3 ,  x: 2, y: 3 ,  x: 1, y: 3  ]

console.log(uniqBy(arr2, 'y'), '哈哈哈哈') // [x:1, y:3]

console.log(uniqBy(arr2, 'x'), '哈哈哈哈') //  [  x: 1, y: 3 ,  x: 2, y: 3 ]

以上是关于lodash好用系列- json数组,根据指定key去重的主要内容,如果未能解决你的问题,请参考以下文章