0

让我们说我们有一个看起来像这样的对象。

    // 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']
4

1 回答 1

3

你可以.filter()

var result = company.employees.employeeID.filter(function(employee) {
    return employee.department === 'accounting';
});
于 2013-04-22T21:24:00.033 回答