📜  obj[key].includes 不是函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:48.045000             🧑  作者: Mango

代码示例1
// Try using Object.values instead:

var aa = [{id: 1,type: 1,status: 1,name: 'txt'},{id: 2,type: 1,status: 1,name: 'txt'},{id: 3,type: 0,status: 0,name: 'txt'}];

function filterIt(arr, searchKey) {
  return arr.filter(function(obj) {
    return Object.values(obj).includes(searchKey);
  });
}

console.log(filterIt(aa, 'txt'));