I want to compare objects in two arrays and if they are not the same, add them to the array.
first array
[
{
"email": "[email protected]"
},
{
"email": "[email protected]"
},
{
"email": "[email protected]"
},
{
"email": "[email protected]"
}
]
secund array
[
{
"email": "[email protected]"
},
{
"email": "[email protected]"
},
{
"email": "[email protected]"
}
]
checking function
if($scope.participants.length > 0){
result.forEach(function (resultElement) {
if(!$scope.participants.includes(resultElement) ) {
$scope.participants.push(resultElement);
}
})
result = [];
console.log($scope.participants);
}
I checked the debug and it drops on the if condition.