📅  最后修改于: 2022-03-11 14:55:28.632000             🧑  作者: Mango
//link
// https://stackoverflow.com/questions/57861821/how-to-return-specific-values-from-a-filter-in-javascript
var animals = [
{id:1, name:"cat"},
{id:2, name:"dog"},
{id:3, name:"fish"}
];
var selected = [1,2];
var selectedAnimals = animals.filter(animal => selected.includes(animal.id));
console.log(selectedAnimals);