ES6 比较两个数组 是否含有相同项
作者:互联网
let array = [
{ id: 1, name: '123' },
{ id: 2, name: '456' },
{ id: 3, name: '678' },
{ id: 4, name: '789' },
{ id: 5, name: '234' }
]
let tempArray= [3, 4]
let date = array.filter(item => tempArray.indexOf(item.id) > -1)
console.log('date', date)
// { id: 3, name: '678' }
// { id: 4, name: '789' }
标签:ES6,678,name,含有,tempArray,let,数组,date,id 来源: https://blog.csdn.net/qq_38946996/article/details/113773724