Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

JavaScript find array of String and Array Object without duplicates ?

By M.K. Verma · 3 May 2022

JavaScript find array of String and Array Object without duplicates ?

You can use lodash chain to solve that:

const result = _([...arr1, ...arr2.map(i => i.email)]) // ['test@email', 'test2@email', 'test@email']
    .countBy() // { test@email: 2, test2@email: 1 }
    .pickBy(count => count === 1) // { test2@email: 1 }
    .keys() // ['test2@email']
    .value();