Skip to content

Instantly share code, notes, and snippets.

@framp
Created November 9, 2015 14:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save framp/546724738d85a072d971 to your computer and use it in GitHub Desktop.
Save framp/546724738d85a072d971 to your computer and use it in GitHub Desktop.
var a = [{ value:"4a55eff3-1e0d-4a81-9105-3ddd7521d642", display:"Jamsheer"}, { value:"644838b3-604d-4899-8b78-09e4799f586f", display:"Muhammed"}, { value:"b6ee537a-375c-45bd-b9d4-4dd84a75041d", display:"Ravi"}, { value:"e97339e1-939d-47ab-974c-1b68c9cfb536", display:"Ajmal"}, { value:"a63a6f77-c637-454e-abf2-dfb9b543af6c", display:"Ryan"}];
var b = [{ value:"4a55eff3-1e0d-4a81-9105-3ddd7521d642", display:"Jamsheer", $$hashKey:"008"}, { value:"644838b3-604d-4899-8b78-09e4799f586f", display:"Muhammed", $$hashKey:"009"}, { value:"b6ee537a-375c-45bd-b9d4-4dd84a75041d", display:"Ravi", $$hashKey:"00A"}, { value:"e97339e1-939d-47ab-974c-1b68c9cfb536", display:"Ajmal", $$hashKey:"00B"}];
var onlyInFirst = function(equal, a, b){
return a.filter(function(current){
return b.filter(equal(current)).length == 0
});
}
var onlyInFirstMyObject = onlyInFirst.bind(0, function equal(a){
return function(b){
return a.value == b.value &&
a.display == b.display
}
});
var result = onlyInFirstMyObject(a,b).concat(onlyInFirstMyObject(b,a));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment