I have searched a lot on internet and I thought this would be a really simple task but I have not found any solution for this
These are my two array of objects
First array
[
{ id: 2, fees: 10000, name: 'Yearly Plan', cycle: 12 },
{ id: 3, fees: 1500, name: 'Two Months Plan', cycle: 2 },
{ id: 4, fees: 2500, name: 'Three Months Plan', cycle: 3 },
{ id: 5, fees: 3000, name: 'Four Months Plan', cycle: 4 },
{ id: 181, fees: 4000, name: 'Five Months Plan', cycle: 5 },
{ id: 182, fees: 5000, name: 'Six Months Plan', cycle: 6 },
{ id: 183, fees: 6000, name: 'Seven Months Plan', cycle: 7 }
]
Second array
[
{ id: 2, fees: 10000, name: 'Yearly Plan', cycle: 12 },
{ id: 3, fees: 1500, name: 'Two Months Plan', cycle: 2 },
{ id: 4, fees: 2500, name: 'Three Months Plan', cycle: 3 }
]
I want to get difference between two array of Objects and I want result something like this
First array - Second array = ( array of objects which are there in first array but not there in second array )
[ { id: 5, fees: 3000, name: 'Four Months Plan', cycle: 4 },
{ id: 181, fees: 4000, name: 'Five Months Plan', cycle: 5 },
{ id: 182, fees: 5000, name: 'Six Months Plan', cycle: 6 },
{ id: 183, fees: 6000, name: 'Seven Months Plan', cycle: 7 } ]
I have tried many many methods like filter like this
let c = existingBillPlans.filter(item =>
!billPlans.some(other => item.x == other.x));
but it is giving null array . Not able to understand what I should do .