I have checked similar questions but they either remove duplicate by using a single key or its comparison between two array of object, here I have an array of object where i want to remove objects if they have same id and and same code. if p_id and c_code is same remove
const arr = filter(this.campaignArr, el => {
if (el.p_id== el.p_id && el.c_code== el.c_code) {
return el;
}
});
console.log(arr)
[{id:"1", p_id:"mobile", c_code:"aaa"},
{id:"1", p_id:"mobile", c_code:"aaa"},
{id:"2", p_id:"electronics", c_code:"aaa"},
{id:"1", p_id:"mobile", c_code:"bbb"},
{id:"2", p_id:"electronics", c_code:"bbb"},
{id:"2", p_id:"electronics", c_code:"bbb"}]
expected output
[{id:"1", p_id:"mobile", c_code:"aaa"},
{id:"2", p_id:"electronics", c_code:"aaa"},
{id:"1", p_id:"mobile", c_code:"bbb"},
{id:"2", p_id:"electronics", c_code:"bbb"}]