查询数组发生重复的这一部门数据

var a = result.Items;
/*
查询json数组中重复的部分
*/
var cf=[];
function countId(data){
var count={};
for(var i=0;i<data.length;i++){
if(count[data[i].OpporunityId]){
count[data[i].OpporunityId]++;
continue;
}
count[data[i].OpporunityId]=1;
}
return count;
}
var result1= countId(a);
for(var i in result1){
if(result1[i]>1){
//console.log(i);//这个是重复出现的id
var cf_son = {OpporunityId:i};
cf.push(cf_son);
}
}
console.log(cf);//这个结果便是在数组中重复出现的字段

posted @ 2017-12-27 08:35  一叶*秋  阅读(152)  评论(0编辑  收藏  举报

博客侧边栏公告广告位招租