I have an array with objects:
let arr = [ { name: 'Jahn', email: 'john@test.com' }, { name: 'Bob', email: 'bob@test.com' } ] I need to add objects. How can I add only unique objects. For example, how can you add only unique objects from such an array?
let arr2 = [ { name: 'Max', email: 'max@test.com' }, { name: 'Bob', email: 'bob@test.com' }, { name: 'Jahn', email: 'john@test.com' }, { name: 'Julie', email: 'julie@test.com' } ] This should result in:
let result = [ { name: 'Jahn', email: 'john@test.com' }, { name: 'Bob', email: 'bob@test.com' }, { name: 'Max', email: 'max@test.com' }, { name: 'Julie', email: 'julie@test.com' } ] The unique property of the object is email
let users = {'example@gmail.com': {....}};? or in the context of your problem the current solution does not fit? - Arendach