数组根据对象的某个属性去重去重

way 1

self.addNewField = self.addNewField.filter(function(element, index) {
          return element['id'] != self.relateFromDialogData.id; 
        });

way2

var obj = {}
                self.fieldList = self.fieldList.reduce(function (s, next) {
                  obj[next.id] ? '' : obj[next.id] = true && s.push(next);      return s;
                }, []);

你可能感兴趣的:(数组根据对象的某个属性去重去重)