I am able to get the difference between two arrays of objects using _.differenceWith like this:
_.differenceWith(arr1, arr2, _.isEqual)
Suppose I have arr1 and arr2 as:
let arr1= [
{
id:1,
val1:{
pre:1,
foo:2
}
}
]
let arr2= [
{
id:3,
val1:{
pre:1,
foo:2
}
},
]
The ids are different, but the val1 properties are same.
So, I want to compare the arrays excluding id.
How can I achieve this using lodash or simple JS?
So, I want to compare the arrays excluding id.So what if later you addval2, or some other property?, as the accepted answer will fail there..