直接上代码
let str = 'apple'; let obj = {}; let number = 0; let activeIndex = ''; [...str].map(key => { key in obj ? obj[key]++ : (obj[key] = 1); obj[key] > number ? (activeIndex = key) : ''; number = obj[key]; }); console.log(activeIndex); // p