var ss = [
{
index:3,
name:"123",
tel:"123456"
},
{
index:0,
name:"123",
tel:"123456"
},
{
index:1,
name:"456",
tel:"123456"
},
{
index:2,
name:"789",
tel:"123456"
},
{
index:4,
name:"789",
tel:"123456"
},
]
function filterObj(obj,filterFields){
var fun = (t,item)=>{
var f = [];
filterFields.forEach(s=>{
f.push(_=>{
return t[s] == item[s];
})
})
return (f.filter(i=>i() === true)).length == f.length;
}
return obj.filter((item,index)=>{
return obj.findIndex(t=>fun(t,item) === true) == index;
// return ss.findIndex(t=>t.name==item.name && t.tel == item.tel) == index;
})
}
console.log(filterObj(ss,['name','tel']));
console