Lets说我们有一个看起来像这样的对象。
// first name - of employee 3
company.employees.employeeId[3].first
// last name - of employee 3
company.employees.employeeId[3].last
// department - of employee 3
company.employees.employeeId[3].department
是否有方法/库来执行这样的查询
// looking for all employees in department Z
result = company.employees.[*].department['accounting']
答案 0 :(得分:3)
你可以.filter()
他们:
var result = company.employees.employeeID.filter(function(employee) {
return employee.department === 'accounting';
});