我想根据另一个数组过滤具有数组属性的对象数组:
[
{
id: 50,
name: 'test1',
countries: ['RO','GB'],
}, {
id: 51,
name: 'test2',
countries: ['DE', 'RO'],
}, {
id: 52,
name: 'test3',
countries: ['DE'],
}
]
我想返回一个对象数组,这些对象可以通过一组国家/地区进行过滤,这意味着如果我想通过 1、2 个国家/地区进行过滤。
1. countries: ['RO']
或者
2. countries: ['RO', 'DE'],
预期输出将是:
1.
[
{
id: 50,
name: 'test1',
countries: ['RO', 'DE' ,'GB'],
}, {
id: 51,
name: 'test2',
countries: ['DE', 'RO'],
}
]
2.
[
{
id: 50,
name: 'test1',
countries: ['RO', 'DE' ,'GB'],
}, {
id: 51,
name: 'test2',
countries: ['DE', 'RO'],
}, {
id: 52,
name: 'test3',
countries: ['DE'],
}
]
慕容708150
慕娘9325324
相关分类