Created
January 25, 2023 05:02
-
-
Save AshishKapoor/9f21856fcf824035f474604f40b0a641 to your computer and use it in GitHub Desktop.
To find difference between array of objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arrayOne = [ | |
{ value: "4a55eff3-1e0d-4a81-9105-3ddd7521d642", display: "Ashish" }, | |
{ value: "644838b3-604d-4899-8b78-09e4799f586f", display: "Kapoor" }, | |
{ value: "b6ee537a-375c-45bd-b9d4-4dd84a75041d", display: "Pulkit" }, | |
{ value: "e97339e1-939d-47ab-974c-1b68c9cfb536", display: "Smriti" }, | |
{ value: "a63a6f77-c637-454e-abf2-dfb9b543af6c", display: "Neeru" }, | |
]; | |
const arrayTwo = [ | |
{ value: "4a55eff3-1e0d-4a81-9105-3ddd7521d642", display: "Ashish"}, | |
{ value: "644838b3-604d-4899-8b78-09e4799f586f", display: "Kapoor"}, | |
{ value: "b6ee537a-375c-45bd-b9d4-4dd84a75041d", display: "Rajesh"}, | |
{ value: "e97339e1-939d-47ab-974c-1b68c9cfb536", display: "Aisha"}, | |
]; | |
const results = arrayOne.filter(({ value: id1 }) => !arrayTwo.some(({ value: id2 }) => id2 === id1)); | |
console.log(results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment