var a = ["a","","","","b","","","c",""];计算后的结果是{a:3,b:2,c:1}
1 回答
回首忆惘然
TA贡献1847条经验 获得超11个赞
var a = ['a', '', '', '', 'b', '', '', 'c', ''];let b = a.reduce((d, v) => void (v ? (d.k = v) && (d.v[v] = 0) : d.v[d.k] += 1) || d, {v: {}, k: ''}).v;console.log(b);
添加回答
举报
0/150
提交
取消