📜  过滤好友数组javascript代码示例

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

代码示例1
var namesArray = [
  { name: 'John', friend: 'Steve', brother: 'Jeff', sister: 'Karen' },
  { name: 'Sarah', friend: 'Joan', brother: 'Marvin', sister: 'Diana' },
  { name: 'Morris', friend: 'Tanya', brother: 'Mike', sister: 'Lisa' },
  { name: 'Brian', friend: 'Tim', brother: 'Andrew', sister: 'Tanya' },
];

var tanyaOnly = namesArray.filter(e => Object.values(e).indexOf("Tanya") > -1);

console.log(tanyaOnly);