Lodash remove duplicates from array

后端 未结 7 693
慢半拍i
慢半拍i 2020-11-29 17:12

This is my data:

[
    {
        url: \'www.example.com/hello\',
        id: \"22\"    
    },
    {
        u         


        
7条回答
  •  鱼传尺愫
    2020-11-29 17:41

    You could use lodash method _.uniqWith, it is available in the current version of lodash 4.17.2.

    Example:

    var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
    
    _.uniqWith(objects, _.isEqual);
    // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
    

    More info: https://lodash.com/docs/#uniqWith

提交回复
热议问题