将数组值相同的索引分为一组 [Group array index by value]

将数组值相同的索引分为一组 [Group array index by value]

1
2
3
4
5
6
7
["aa", "er", "ewr", "er", "as", "asfad", "asfad", "vvv", "aa"].reduce(
(accumulator, seed, index) => {
accumulator[seed] = (accumulator[seed] || []).concat(index);
return accumulator;
},
{}
);

将数组值相同的索引分为一组 [Group array index by value]
https://tedding.dev/2023/03/14/186deb01498.html
作者
TED.DING
发布于
2023年3月14日
许可协议