JavaScript - Filter Nested Arrays

arr2.filter(function(obj) {

  obj.filter(function(d) { 

    if(d.id == ID) { 

      result = d;

    }

  })

});

alert(result.name);

Hope this is what you were looking for. Rather than flattening the data here I went into the nested array till the point where it was flat(and matching) and set the result there.

arr2.forEach(function(d) {

  d.forEach(

    function(dd){ 

      alert(dd.id);

      if (dd.id==ID){

        result=dd; 

      }

    }

  );

});

alert(result.name);

Edit: As minitech mentioned its same working if just using forEach.


Flatten the array then filter it:

arr.reduce(function(a,b) { return a.concat(b);  })
   .filter(function(obj) { return obj.id == ID; });