Skip to content

Instantly share code, notes, and snippets.

@muhammadawaisshaikh
Created February 27, 2020 14:23
Show Gist options
  • Select an option

  • Save muhammadawaisshaikh/df40f53b01f1f223e231229361478285 to your computer and use it in GitHub Desktop.

Select an option

Save muhammadawaisshaikh/df40f53b01f1f223e231229361478285 to your computer and use it in GitHub Desktop.
check if any object is same in two array of abjects
// check if any object is same in two array of abjects
const matchedRoles = [];
allRoles.forEach(role => {
const matchRoles = userRoles.map(userRole => {
if (role.id === userRole.id) {
// console.log(userRole.id);
matchedRoles.push(userRole.id);
// console.log(matchedRoles.indexOf(userRole.id))
}
});
});
console.log(matchedRoles);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment