vara=["a","","","","b","","","c",""];计算后的结果是{a:3,b:2,c:1}
2 回答
阿晨1998
TA贡献2037条经验 获得超6个赞
((a,_)=>a.reduce((p,c)=>[_=c||_,_&&[p[_]=p[_]||0,!c&&(p[_]++)],p][2],{}))(["a","","","","b","","","c",""],undefined)会忽略第一个非空字符前的所有空字符。
添加回答
举报
0/150
提交
取消