I want to remove duplicates from an array of objects can anyone help with this to remove duplicates in the array of objects. I have an array of array of objects that I want to remove duplicates and I want to use
const firstArray = [
{
first: "01",
data: [
{ id: "01", name: "test1" },
{ id: "02", name: "test2" },
{ id: "03", name: "test3" },
{ id: "05", name: "test1" },
{ id: "06", name: "test2" },
{ id: "07", name: "test1" }
]
},
{
first: "02",
data: [
{ id: "01", name: "test2" },
{ id: "02", name: "test1" },
{ id: "03", name: "test3" },
{ id: "05", name: "test2" },
{ id: "06", name: "test2" },
{ id: "07", name: "test1" }
]
},
{
first: "03",
data: [
{ id: "01", name: "test3" },
{ id: "02", name: "test2" },
{ id: "03", name: "test3" },
{ id: "04", name: "test2" },
{ id: "05", name: "test3" },
{ id: "07", name: "test1" }
]
}
];
this is the sample result code i am expecting :
const firstArray = [
{
first: "01",
data: [
{ id: "01", name: "test1" },
{ id: "02", name: "test2" },
{ id: "03", name: "test3" },
]
},
{
first: "02",
data: [
{ id: "01", name: "test1" },
{ id: "02", name: "test2" },
{ id: "03", name: "test3" },
]
},
{
first: "03",
data: [
{ id: "05", name: "test1" },
{ id: "06", name: "test2" },
{ id: "07", name: "test3" }
]
}
];```
namevalue of adataitem within each separatedataarray), the OP him/herself might get more clear about an own approach. The most important information for any approach of cause was whether one wants another array as result or one wants to mutate the original(ly provided) array reference (herefirstArray).