js统计,然后去重例子

 var list=new Array();
for(var i=0;i<result.length;i++){
examsubject=result[i].examsubject;
list.add(parseInt(examsubject));
}
//统计相同科目的个数,也就是单个科目的座位总数
var map = {};
for(var i = 0;i < list.length;i++)
{
var ai = list[i];
if (!map[ai])
{
map[ai] = 1;
}
else
{
map[ai]++;
}
}
var arr=[];
for(var key in map){
var examsubjectid=key;
var examsubjectname=LEAP.getCodeText("LSIP_examsubject",examsubjectid);
var examtypename=LEAP.getCodeText("LSIP_examtype",50);
var seatnumber=map[key];
var ar={
"companyname":"职业技术考试中心",
"companyno":"8000",
"examsubjectname":examsubjectname,
"examsubjectid":examsubjectid,
"examtypeid":"50",
"examtypename":examtypename,
"seatnumber":seatnumber
};
arr.push(ar);
}
上一篇:一步步优化JVM五:优化延迟或者响应时间


下一篇:Java之事务的基本应用