📌  相关文章
📜  lodash 查找重复元素索引 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:38.655000             🧑  作者: Mango

代码示例1
const _ = require('lodash');
let arr = ["a", "a", "b", "c", "c", "a"];

let result = _.omitBy(
  _.reduce(arr, (a, v, i) => _.set(a, v, (a[v] || []).concat([i])), {} ),
  v => v.length <= 1
);

console.log(result);