I have a table and a searchbox. I want to search all objects in array. When I type John, I want two objects to return because they are in the first and last name parts, and they are in both fields.
For example:
myArray = [
{id:1, name:'John', surname:'Vardy'},
{id:2, name:'Pepe', surname:'Vardy'},
{id:3, name:'Phil', surname:'John'},
]
>Solution :
You can combine filter with a search in Object.values:
found = myArray.filter(obj =>
Object.values(obj).includes(searchString))