How to use underscore's “intersection” on objects?

后端 未结 10 1126
春和景丽
春和景丽 2020-12-02 15:49
_.intersection([], [])

only works with primitive types, right?

It doesn\'t work with objects. How can I make it work with objects (maybe b

10条回答
  •  离开以前
    2020-12-02 16:09

    //nested array is in the format of [[],[],[]]
    
    function objectArrayIntersection(nestedArrays){     
    
        let intersectingItems = [];                
        let uniqArr = _.uniq(_.flatten(nestedArrays)); //intersecting items removed    
        const countOfNestedArrays = nestedArrays.length;
    
    
        for (let index = 0; index < uniqArr.length; index++) {
            let uniqItem = uniqArr[index];
            let foundCount = 0;
    
            for(var j = 0;j

    I tried solving it this way.

提交回复
热议问题