【发布时间】:2021-06-10 15:55:29
【问题描述】:
我正在尝试根据嵌套数据过滤顶级对象(嵌套对象也需要过滤)。
过滤参数:所有具有 categoryValue A 的记录。
const table = [
{
name: 'Bob',
detail: [
{ category: 'Employeer', categoryValue: 'A' },
{ category: 'Employeer', categoryValue: 'B' },
],
},
{
name: 'Alice',
detail: [
{ category: 'Employeer', categoryValue: 'C' },
{ category: 'Employeer', categoryValue: 'D' },
],
},
];
我期待以下结果
const fileredTable = [
{
//this
name: 'Bob',
detail: [
//and only this
{ category: 'Employeer', categoryValue: 'A' }
],
}
];
【问题讨论】:
标签: javascript filter lodash