const notes = {
'jk2334|notes-md-23': {
id: 'notes-md-23',
text: 'First Note'
},
'jk2334|notes-xd-34': {
id: 'notes-xd-34',
text: 'Second Note'
},
'fd4345|notes-mf-54': {
id: 'notes-mf-54',
text: 'Third Note'
}
}
const result = Object.keys(notes).filter(note => {
if(note.startsWith('jk2334')) {
console.log('from inner -', notes[note]);
return notes[note];
}
})
console.log(result)Run Code Online (Sandbox Code Playgroud)
如果我运行此代码,它仅返回键,而不返回对象的值。但如果我在条件内进行控制台,它会返回值。
我想返回值数组而不是键。我现在应该怎么做?