var s = 'aaabbbcccaaabbbaaa';var obj = {};var maxn = -1;var letter;for(var i = 0; i < s.length; i++) { if(obj[s[i]]) { obj[s[i]]++; if(obj[s[i]] > maxn) { maxn = obj[s[i]]; letter = s[i]; } } else { obj[s[i]] = 1; if(obj[s[i]] > maxn) { maxn = obj[s[i]]; letter = s[i]; } }} alert(letter + ': ' + maxn);這里面的obj[s[i]]什么意思 為什么要定義obj[s[i]]++和obj[s[i]]=1
大神們幫我看看這段代碼關(guān)于JS去重的
猛跑小豬
2018-09-14 12:14:06