Say I have an array like this: [1, 1, 2, 2, 3]
[1, 1, 2, 2, 3]
I want to get the duplicates which are in this case: [1, 2]
[1, 2]
Does lodash support thi
No need to use lodash, you can use following code:
lodash
function getDuplicates(array, key) { return array.filter(e1=>{ if(array.filter(e2=>{ return e1[key] === e2[key]; }).length > 1) { return e1; } }) }