Remove duplicate array of objects according to a certain number of properties

1. array object, an object is calculated based on the number of repeated

E.g:

the getData () { 
  the let arrData = [{ 
    'A': 'you', 
    'B': '. 1', 
    'C': 'His' 
  }, { 
    'A': 'His', 
    'B': '2' , 
    'C': "it" 
  }, { 
    'A': 'you', 
    'B': '. 3', 
    'C': "it" 
  }, { 
    'A': 'his', 
    ' B ':' . 4 ', 
    ' C ': "it" 
  }, { 
    ' A ':' it ', 
    ' B ':'. 5 ', 
    ' C ': "it" 
  }] 
  this.getWordCnt (ARR) 
},

Calculation function

// The level data calculation is repeated the number 
getWordCnt (ARR) { 
  the let arrData ARR = 
  the let obj = {} 
  for (the let I = 0; I <arrData.length; I ++) { 
    var = arrData Item [I] II.A / / a of the calculated properties, can be replaced by B, C 
    obj [Item] = (obj [Item] +. 1). 1 || 
  } 
  the console.log (obj) 
  return obj 
},

Print results

 

Guess you like

Origin www.cnblogs.com/wgl0126/p/11596956.html