I have a filter function, which uses filter to quickly search a text in an array:
filtered = filtered.filter((row) => {
return Object.keys(row).some((key) => {
return String(row[key]).toLowerCase().indexOf(this.quickSearch.toLowerCase()) > -1
})
})
This works great for single level array, but not sure how to adapt it to work down unknown number of levels of array of objects like this
{
'name': 'james',
'post': {
'name': 'my favorite teams'
}
}
The code above finds james, no problem, but it will not find teams as its not going deep enough.
Naturally I don't want to hardcode something like if row[key] == 'post', because I'm using this code for multiple data sources and need it to be dynamic.
How do I adapt this to work in multi level arrays like the example above?