var a = [ { id: 1, name: 'hong' }, { id: 2, name: 'huang' }, { id: 3, name: 'lan' } ] var b = [ { id: 1, name: 'hong' }, { id: 2, name: 'lan' }, { id: 4, name: 'lv' } ] b.forEach(item => { a = a.filter(a => a.id != item.id) }) console.log(JSON.stringify(a))
原链接: https://www.cnblogs.com/guozongzhang/p/10921550.html