Answers for "filter js object array based on multiple parameters"

0

filter js object array based on multiple parameters

var arr= [{id: "123", name: "Foo"},
          {id: "123", name: "Bar"},
          {id: "345", name: "Foo"},
          {id: "678", name: "FooBar"}
         ];

var name = 'Foo';
var id = '123';

arr = arr.filter(function(elem) {
  //return false for the element that matches both the name and the id
  return !(elem.id == id && elem.name == name)
});
Posted by: Guest on May-03-2021

Code answers related to "filter js object array based on multiple parameters"

Browse Popular Code Answers by Language