[javascript] arrow function

const people = [
  { id: 1, name: 'Ichiro-Tanaka', nation: 'Japan',   gender: 'male'   },
  { id: 2, name: 'Ming-Liu',      nation: 'Tiwan',   gender: 'female' },
  { id: 3, name: 'Fei',           nation: 'China',   gender: 'male'   },
  { id: 4, name: 'Jane-Levy',     nation: 'America', gender: 'female' },
  { id: 5, name: 'Sangwu-Lee',    nation: 'Korea',   gender: 'male'   },
  { id: 6, name: 'Tom-Jackson',   nation: 'England', gender: 'male'   },
  { id: 7, name: 'John-Dow',      nation: 'Gana',    gender: 'male'   },
  { id: 8, name: 'Ken-Nakano',    nation: 'Japan',   gender: 'male'   },
  { id: 8, name: 'Haru-Suzuki',   nation: 'Japan',   gender: 'female' }
];

const selector = (nation, gender) => (member) => member.nation === nation && member.gender === gender;

const findMembersBy = (members, selector) => members.filter(selector);

const res = findMembersBy(people, selector('Japan', 'female'));
console.log(res);
// res: [ { id: 8, name: 'Haru-Suzuki', nation: 'Japan', gender: 'female' } ]

links

social