There is a user array defined as follows:
var users = [{
id: 1,
name: 'ABC',
isDisplay: true
}, {
id: 2,
name: 'XYZ',
isDisplay: true
}, {
id: 3,
name: 'JKL',
isDisplay: true
}];
Additionally, there is another array called selectedUsers which contains specific objects from the above array:
var selectedUsers = [{
id: 1,
name: 'ABC'
},
{
id: 3,
name: 'JKL'
}];
I want to determine which objects exist in the second array based on their ID
, without using lodash.
_.each(users, (_u) => {
if(selectedUsers.includes(_u)) {
_u.isDisplay = false;
} else {
_u.isDisplay = true;
}
});
My attempt to match entire objects using includes
did not work because AngularJS automatically adds a $$hashkey property to objects. Is there an alternative method to achieve this?