Compare two arrays of objects and remove items in the second one that have the same property value

FIDDLE

 for (var i = 0, len = a.length; i < len; i++) { 
        for (var j = 0, len2 = b.length; j < len2; j++) { 
            if (a[i].name === b[j].name) {
                b.splice(j, 1);
                len2=b.length;
            }
        }
    }

Instead of using two loops you might also use the findIndex function:

for (var i = 0, len = a.length; i < len; i++) {
    var ItemIndex = b.findIndex(b => b.name === a[i].name);

    a.splice(ItemIndex, 1)
}

Or if you want to go completely without using a loop you might use the forEach function

a.forEach(function(item, index, array) {
    var ItemIndex = b.findIndex(b => b.name === item.name);

    a.splice(ItemIndex, 1)
}

Your problem is, that splice() will change the length of the array, so that your precalculated len value will be too large and the inside the loop you try to access undefined elements.

A possible solution would be to use the filter() method:

function remove_duplicates(a, b) {

  b = b.filter( function( item ) {
      for( var i=0, len=a.length; i<len; i++ ){
          if( a[i].name == item.name ) {
              return false;
          }
      }
      return true;
  });

  console.log(a);
  console.log(b);
}

Example Fiddle