I have 2 array of object, just want to check b exist in a, if yes add a new property. but the length of b is dynamic. I will got error of undefined of b.
var a = [{name:'john'},{name:'james'},{name:'jordan'},{name:'joe'}];
var b = [{name:'john'},{name:'joe'}];
var exist = 0;
var c = _.map(a,function(result,i){
exist = b[i].name.indexOf(a.name) > -1 ? exist = 1 : exist = 0;
return _.extend({},c,{'exist':exist});
});
any clue?