I have two JavaScript arrays which contain objects, like this:
var array1 = [{'123': '18'}, {'578': '2'}, {'323': '5'}];
var array2 = [{'123': '18'}, {'578': '1'}, {'323': '3'}];
Each array will have the same keys as the other (though perhaps not in the same order). However, the values may be different for a given key. What I want is an array of the objects in array2 that have different values for the same key in array1. So, for this example, I want:
[{'578': '1'}, {'323': '3'}]
What I have tried
I've tried to do this with jQuery's .inArray() and .grep() methods, but these are handing me back every object, not just the ones with changed values:
difference = $.grep(array1,function(x) {
  return $.inArray(x, array2) < 0
})
Here is my fiddle. jQuery or regular JavaScript (or even Angular) solutions would be great. Thanks.
 
     
     
     
     
     
     
     
    