统计字符串中出现的字母
let str = "aabbabbbcchhddfgh"; let obj = {}; for(var v of str){ if(obj[v]&&obj[v].value == v){ obj[v].count = ++obj[v].count; }else{ obj[v] = {}; obj[v].count = 1; obj[v].value = v; } } for(key in obj){ console.log(obj[key].value + '=' + obj[key].count + '');