how to compare two array of object .
i have a two json array
array1
[{“subjectId”:“2”},{“subjectId”:“4”},{“subjectId”:“1”}];
array2
[{"vdoSub_id":"1","vdoSub_name":"Art & Design","vdoSub_desc":"Here have some various art & design videos"},
{"vdoSub_id":"2","vdoSub_name":"Comedy","vdoSub_desc":"Here we have some funny comedy videos. Please watch, like and share with your friends and family member."},
{"vdoSub_id":"3","vdoSub_name":"Music","vdoSub_desc":"Here music destination featuring top tracks and popular hits from a variety of genres."},
{"vdoSub_id":"4","vdoSub_name":"java","vdoSub_desc":"higjghjfhjfhhjfjhjghfjfgj"},
{"vdoSub_id":"5","vdoSub_name":"XYZA","vdoSub_desc":"wgqghqwhgqer6yjke65533"}];
I try to match like this
if(this.all[j].subjectId==this.allVideoSubject[i.vdoSub_id]){
newarray.push({
"subjectName":this.allVideoSubject[i].vdoSub_name,
})
}else{
newarray1.push({
"subjectName":this.allVideoSubject[i].vdoSub_name,
})
My question is that match value properly push into newarray
but unmatched value repeatedly push into newarray1
but i want to do that match value push into newarray
unmatched value push into newarray1
how can i do that.
Thanks
}