I have 2 arrays of objects. One array receives the data from the API and renders it in the application, the other receives the data from localStorage, which are data from the first and which have been changed and stored in localStorage. I want to concatenate these two arrays, but I need to remove the repeated data in order not to render the same object twice.
example of what I hope:
dado1 = [
{customer: {
purchased: false,
id: 1
}},
{customer: {
purchased: false,
id: 2
}}
]
dado2 = [
{customer: {
purchased: true,
id: 1
}}
]
dado3 = dado1.concat (dado2)
result:
dado3 = [
{customer: {
purchased: true,
id: 1
}},
{customer: {
purchased: false,
id: 2
}}
]
I am not able to compare the two arrays. I've thought of several ways, but I always fail