1
如何过滤数组是否在另一个数组内?过滤内部数组javascript
我该如何循环?
var jobs = [
{
'id': '1',
'departments': [{'name': 'Finance'}],
'offices': [{'name': 'US'}, {'name': 'Brazil'}]
},
{
'id': '1',
'departments': [{'name': 'Finance'}],
'offices': [{'name': 'Paris'}, {'name': 'China'}]
}
];
var results = jobs.filter(function(o)) {
return o.offices[0].name == 'US';
} // get office US;
'jobs.filter(J => j.offices.some(O => o.name === “US”))'使用'some'以查看是否之一“办公室”阵列内的对象符合您的要求。 – user3297291