const _findMostType = array => {
let max = 0;
let res = [];
let map = new Map();
// 统计各类型数量
for(let ele of array){
let type = typeof ele;
if(map.has(type)){
let count = map.get(type);
map.set(type, ++count);
max = Math.max(max, count);
}else{
map.set(type, 1);
}
}
// 计入数量最多的类型
let keys = map.keys();
for(let k of keys){
if(map.get(k) === max){
res.push(k);
}
}
// 最大值
res.push(max);
return res;
}

京公网安备 11010502036488号