我有一个由对象组成的数组。这是一个例子:[{events: Array(5), conditions: {…}},{events: Array(5), conditions: {…}}{conditions: {…}, awaits: Array(0), events: Array(1), pid: "123"}] 如您所见,对象有所不同。有些具有属性“pid”,有些则没有。这就是这个问题的全部内容。我想将带有 pid 的那些分配给一个包含 pid 的对象的新数组。假设这个数组存储在 match.entries 中。嗯,这就是我尝试过的。// aa = match.entries.filter(entry => {return typeof entry.pid !== 'undefined'})这似乎不起作用。我的整个代码: let aa = []; conditionalMatches.forEach(match => { aa = match.entries.filter(entry => {return typeof entry.pid !== 'undefined'}) });返回空数组。
添加回答
举报
0/150
提交
取消