I want to delete rows from an object array that have the same id
, but other keys are different.
For example, I have the following Array:
testArray = [
{id: 1, type: 1}
{id: 2, type: undefined}
{id: 3, type: 0}
{id: 3, type: undefined}
{id: 4, type: 0}
];
testArray[2] and testArray[3] have the same id value, but I want to delete the one that has the type undefined
.
Final array should look like:
testArray = [
{id: 1, type: 1}
{id: 2, type: undefined}
{id: 3, type: 0}
{id: 4, type: 0}
];