Answers for "doing a filter between two array and returining single property"

1

filter out object in array using two arguments

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

var name = 'FaaBar';
var id = '678';

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 June-25-2020

Code answers related to "doing a filter between two array and returining single property"

Code answers related to "Javascript"

Browse Popular Code Answers by Language