Question: I've got two arrays of objects, the difference between them is only that arrayAfter will have an element added:

```
var arrayBefore = [
  {"name":"Alan","height":"171","weight":"66"},
  {"name":"Ben","height":"182","weight":"90"}
 ];

var arrayAfter= [
  {"name":"Alan","height":"171","weight":"66"},
  {"name":"Ben","height":"182","weight":"90"},
  {"name":"Chris","height":"163","weight":"71"}
 ];

```

"name" is always unique!

How can I find out which one is the element that has been added? I've tried ending up using nested for loops, but this seems overcomplicated. 

I've also found the this nice idea:

```
var diff = $(arrayAfter).not(arrayBefore ).get();

```

However, that does not seem to work on arrays of objects straight ahead.

**Is there some easy way to get the difference?**

Answer: 
If only the name indicates uniqueness, you can do:

```
//Get a list of all the names in the before array
var beforeNames = arrayBefore.map(function(person) { return person.name });

//Filter the after array to only contain names not contained in the before array
var uniqueObjects = arrayAfter.filter(function(person) {
    return beforeNames.indexOf(person.name) === -1;
});

console.log(uniqueObjects); //[{"name":"Chris","height":"163","weight":"71"}]

```

Demo: <http://jsfiddle.net/tehgc8L5/>
I believe jQuery will have nothing that will directly solve your problem here. Your problem being comparing objects for equality. 

I am assuming that name is unique. If not, for this method you will need a unique identifier for data. If you absolute do not have one then you could concat all data to get one.

```
// first make a map of objects in before
var before = {};
arrayBefore.forEach(function(o){
   before[o.name] = o;
});

// now we get the elements of after that do not exist in our hashmap
var result = arrayAfter.filter(function(o){
    return !(o.name in before);
});

```

You can obviously wrap this up in a general function.