Код: Выделить всё
const customers = [
{ id: 1, email: 'test@example.com', name: 'John' },
{ id: 2, email: 'test@example.com', name: 'Jane' },
{ id: 3, email: 'other@example.com', name: 'Bob' }
];
const duplicates = customers.filter((customer, index, arr) =>
arr.findIndex(c => c.email === customer.email) !== index
);
console.log(duplicates); // Expected: [{id: 2, ...}] but got: []
Подробнее здесь: https://stackoverflow.com/questions/798 ... -valid-dat