filter an array of objects (like angualr.js |filter)
علی ذوالفقار
1403/06/24 16:30:42 (59)
const fullFilter = (items, searchText) => {
if (!searchText) {
return items; // if not searchText return all data
}
return items.filter( (item) => {
for (var key in item) { // loop in key values in each item
if (item[key].toString().toLowerCase().includes(searchText.toLowerCase())) {
return true;
}
}
return false;
});
};
console.log(fullFilter(items,'1'))