Javascript: filter array of objects by array of strings

You can use indexOf in filter, like this

var res = a.filter(function (el) {
  return kpis.indexOf(el.id) >= 0; 
});

Example

Leave a Comment