📌  相关文章
📜  如何通过javascript代码示例中的对象列表过滤数组

📅  最后修改于: 2022-03-11 15:02:15.895000             🧑  作者: Mango

代码示例4
let people = [
  { name: "Steve", age: 27, country: "America" },
  { name: "Jacob", age: 24, country: "America" }
];

let filteredPeople = people.filter(function (currentElement) {
  // the current value is an object, so you can check on its properties
  return currentElement.country === "America" && currentElement.age < 25;
});

console.log(filteredPeople);
// [{ name: "Jacob", age: 24, country: "America" }]