let arr = [{ id: 1, name: 'a' }, { id: 2, name: 'b' }, { id: 3, name: 'c' }, { id: 4, name: 'd' }, { id: 5, name: 'e' },]
let sum = [3, 4, 5]
let date = arr.filter(item => sum.indexOf(item.id) > -1)
console.log('date', date)
// 0: {id: 3, name: "c"}
// 1: {id: 4, name: "d"}
// 2: {id: 5, name: "e"}
es6两个数组取相同值
最新推荐文章于 2023-10-07 16:41:59 发布