var countArr = [1,2,3,4,5,6,3,4,3,3,7,8,9,32,1,11,2,3,3,3];
var res = {};
var maxnum=0;
var max;
function getRepeat(arr){
for (var i = 0; i < arr.length; i++) {
if(!res[arr[i]]){
res[arr[i]] = 1;
}else{
res[arr[i]] ++;
}
};
var keys = Object.keys(res);
console.log(keys);
for(var j=0;j<keys.length;j++){
if(res[keys[j]] > maxnum){
maxnum = res[keys[j]];
max = keys[j];
}
}
return maxnum + max
}
getRepeat(countArr);
console.log('出现次数最多的是' + max + '次数为' + maxnum);
输出结果:出现次数最多的是3次数为7