Created
August 24, 2020 17:12
-
-
Save amitkulhari26/2f591c7af781fb8d27da7d9bb2c9e30b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // https://stackoverflow.com/questions/21987909/how-to-get-the-difference-between-two-arrays-of-objects-in-javascript | |
| //Find values that are in result1 but not in result2 | |
| var uniqueResultOne = result1.filter(function(obj) { | |
| return !result2.some(function(obj2) { | |
| return obj.value == obj2.value; | |
| }); | |
| }); | |
| //Find values that are in result2 but not in result1 | |
| var uniqueResultTwo = result2.filter(function(obj) { | |
| return !result1.some(function(obj2) { | |
| return obj.value == obj2.value; | |
| }); | |
| }); | |
| //Combine the two arrays of unique entries | |
| var result = uniqueResultOne.concat(uniqueResultTwo) | |
| // using lodash | |
| import differenceBy from 'lodash/differenceBy' | |
| const myDifferences = differenceBy(Result1, Result2, 'value') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment