要过滤对象数组中某个属性值相等的对象,可以使用过滤函数结合对象属性的比较来实现
// 假设有一个包含学生信息的数组 var students = [ { name: "张三", score: 85 }, { name: "李四", score: 90 }, { name: "王五", score: 78 }, { name: "赵六", score: 95 }, { name: "钱七", score: 88 }, ]; // 使用过滤函数筛选出分数大于等于90的学生 var filteredStudents = students.filter(function (student) { return student.score >= 90; }); console.log(filteredStudents);
标签:函数,过滤,filteredStudents,score,90,name From: https://www.cnblogs.com/xbinbin/p/17660226.html