filter array of objects with array object js code example
Example 1: javascript filter array of objects
let people = [
{ name: "Steve", age: 27, country: "America" },
{ name: "Jacob", age: 24, country: "America" }
];
let filteredPeople = people.filter(function (currentElement) {
return currentElement.country === "America" && currentElement.age < 25;
});
console.log(filteredPeople);
Example 2: javascript filter array of objects by array
var arr = [1,2,3,4],
brr = [2,4],
res = arr.filter(f => !brr.includes(f));
console.log(res);