Following is a sample array that I have. The goal is to determine whether there are duplicate entries based on a number of fields (details below) -
values = [
{
"name": "123",
"loginTime": "01:00:00",
"logoutTime": "01:00:00",
"description": "test",
"message": "test2",
"status": "test3"
},
{
"name": "123",
"loginTime": "01:00:00",
"logoutTime": "00:00:00",
"description": "test",
"message": "test2",
"status": "test3"
},
{
"name": "222",
"loginTime": "01:00:00",
"logoutTime": "00:00:00",
"description": "test2",
"message": "test2",
"status": "test1"
}
]
I am aware of the similar looking popular question here, however, the scenario I'm talking about is different. In that question, the user is concerned mainly about the name field only and so the Set based solution works fine. In my case, however, I need to determine the existence of duplicate data if the name, description, message, status fields are the same between any two entries in values (and so not just one field). So from the example list above, the first two entries are duplicates, since all the mentioned fields have the same value between them. At least one of the aforementioned fields will need to have a non-duplicate value here. What would be an ES6 compliant way to detect the duplicate data here?
A Set based solution makes sense for when there's just one field that we'll have to look into to determine the duplication. Not sure how one would do it for multiple fields.