var a = ["a","","","","b","","","c",""];
计算后的结果是
{
a:3,
b:2,
c:1
}
((a, _) => a.reduce((p, c) =>
[_ = c || _, _ && [p[_] = p[_] || 0, !c && (p[_] ++)], p][2], {}))
(["a","","","","b","","","c",""], undefined)
会忽略第一个非空字符前的所有空字符。
10 回答11.3k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.2k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答2.4k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决