アレイオブジェクトレベル交差点

有以下数据: = 新しいセット([ 
    {
         1: '区分'  'categoryIdLevelOne':750611334  'categoryIdLevelThree':750611336  'categoryIdLevelTwo':750611335  'ID':2697  'レベル':3 「shopId 「:12430  'skipLayoutFlag': 'ステータス':1 
    }、
    {
         '区分':2  'categoryIdLevelOne':750611472  'categoryIdLevelTwo':750611473  'ID':2701 'レベル':2  'shopId':12430  'skipLayoutFlag': 'ステータス':2 
    }、
    {
         '区分':3  'categoryIdLevelOne':750611487  'categoryIdLevelTwo':750611488  'ID':2702  'レベル':2  'shopId':12430  'skipLayoutFlag': 'ステータス':1 
    } 
])
Bせ = 新しいセット([ 
    {
         2: '区分' 'categoryIdLevelOne':750611334  'categoryIdLevelThree':750611336  'categoryIdLevelTwo':750611335  'ID':2697  'レベル':3  'shopId':12430  'skipLayoutFlag': 'ステータス':1 
    }、
    {
         '区分':3  'categoryIdLevelOne':750611472  'categoryIdLevelTwo':750611473  'ID':2701  'レベル':2  'shopId':12430  'skipLayoutFlag': 'ステータス':2 
    }、
    {
         '区分':4  'categoryIdLevelOne':750611487  'categoryIdLevelTwo':750611488  'ID':2702  'レベル':2  'shopId':12430  'skipLayoutFlag': 'ステータス':1 
    } 
])

交集
[...] .filter(X => [... B] .some(Y => y.categoryId === x.categoryId))

// 或者

アレイ。 (A).filter(Xから => Array.from(B).some(Y => y.categoryId === X。区分)) 

の差分セット

[... A] .filter(X => [... B] .every(Y => y.categoryId!== x.categoryId))

去重

 この .selectTable = この .selectTable.reduce(関数(項目次){ 
        ハッシュ[next.id] ""?(ハッシュ[next.id] =  && 次item.push());
         戻り項目; 
      }、[])。

 

おすすめ

転載: www.cnblogs.com/nns4/p/11348148.html
おすすめ