lodash mapby code example
Example 1: diff two arrays lodash
_.difference([2, 1], [2, 3]);
// => [1]
Example 2: lodash find duplicate element index
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);