I need to know the duplicate data regardless of the Id.
This is the array:-
const myArray = [
{id: "sjdh1", userName: "user 1" , Message: ["try","test","test"]},
{id: "sjdh2", userName: "user 2" , Message: ["test","try","test"]},
{id: "sjdh3", userName: "user 3" , Message: ["test"]},
{id: "sjdh4", userName: "user 1" , Message: ["dummy"]},
{id: "sjdh5", userName: "user 1" , Message: ["try","test","test"]},
]
I want to remove the duplicate data. id does not matter
The expected result is:-
const myArray = [
{id: "sjdh1", userName: "user 1" , Message: ["try","test","test"]},
{id: "sjdh2", userName: "user 2" , Message: ["test","try","test"]},
{id: "sjdh3", userName: "user 3" , Message: ["test"]},
{id: "sjdh4", userName: "user 1" , Message: ["dummy"]},
]
Removing the value if the UserName and the Message array is completely Same if the Message array is different then the object should not be considered the duplicate one :
So, I tried to use the set method but I found that it is not working because myArray contains the object.
Then I googled the problem and got this solution but it didnot worked for me :-
const uniqueValues = new Set(array.map(v => v.name));
It gives me the only one key with it's value