//根据confid取配置差异项 function uniqueConfid(arr, num) { //计数 const counts = arr.reduce( (m, x) => ((m[x.confid] = (m[x.confid] || 0) + 1), m), {} ); //去重 const res = new Map(); const newArr = arr.filter(item => { return !res.has(item.confid) && res.set(item.confid, 1); }); //删除最多重复项 return newArr.filter(x => counts[x.confid] !== num); } let arr = [{ confid: 1 }, { confid: 1 }, { confid: 2 }, { confid: 3 }, { confid: 4 }]; console.log('输出结果:', JSON.stringify(uniqueConfid(arr, 2)))