使用es6,对两个数组进行对比,从而修改其中一个数组里的某些值
作者:互联网
条件:arrA,arrB,通过对比修改arrB中的字段值
var sSrr = []; var arrA = [ {name:'这是一',Id:1}, {name:'这是二',Id:2}, {name:'这是三',Id:3}, {name:'这是一',Id:1}, {name:'这是二',Id:2} ] var arrB = [ {name:'这是二',Id:2}, {name:'这是三',Id:3} ] arrA.forEach(i=>{ sSrr.push(i.name+i.Id) }) arrB.forEach(r=>{ if([...new Set(sSrr )].indexOf(r.name+r.Id)>-1){ r.disabled = true }else{ r.disabled = false } })
标签:es6,arrB,arrA,对比,sSrr,数组,var,Id,name 来源: https://www.cnblogs.com/C-target/p/14814108.html