Javascript 筛选器深层嵌套属性返回空数组
我有一个对象数组Javascript 筛选器深层嵌套属性返回空数组,javascript,lodash,ecmascript-harmony,Javascript,Lodash,Ecmascript Harmony,我有一个对象数组 var data = [{type:"A",parentPersonInfo:{id:1,fullname:'john smith'}},{type:"A",parentPersonInfo: {id:1,fullname:'jim smith'}},{type:"B",parentPersonInfo: {id:2,fullname:'jane smith'}}] 我想使用lodash来提取type=A和id=1的记录 const testId = 1; _.fil
var data = [{type:"A",parentPersonInfo:{id:1,fullname:'john smith'}},{type:"A",parentPersonInfo: {id:1,fullname:'jim smith'}},{type:"B",parentPersonInfo: {id:2,fullname:'jane smith'}}]
我想使用lodash来提取type=A和id=1的记录
const testId = 1;
_.filter(data,{'type':'A','data.parentPersonInfo.id':1});
但是我得到[]你能检查一下使用下面的代码是否有效吗
_.filter(data, {type: 'A', parentPersonInfo: {id:1}});
你没有创建MCVE有什么原因吗?@Amit什么是MCVE