let arr = [{ id: 1, name: 'zs' }, { id: 2, name: 'ls' }, { id: 3, name: 'ww' }, { id: 4, name: 'xm' }, { id: 5, name: 'xh' },] let sum = [3, 4, 5] let date = arr.filter(item => sum.indexOf(item.id) > -1) console.log('date', date) // 0: {id: 3, name: "ww"} // 1: {id: 4, name: "xm"} // 2: {id: 5, name: "xh"}
arr.forEach(item => sum.forEach(node=>{ if(item.name== node.name){ item.checked = true item.is_required == node.is_required item.id = node.id } }))