# How to compare two array of object

**URL:** <https://forum.ionicframework.com/t/how-to-compare-two-array-of-object/131126>\
**Category:** ionic-v3\
**Created:** [May 23, 2018, 4:24am UTC](https://forum.ionicframework.com/t/how-to-compare-two-array-of-object/131126 "2018-05-23T04:24:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flycoders\_sourav](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@flycoders\_sourav](https://forum.ionicframework.com/u/flycoders_sourav)\
**Post date:** [May 23, 2018, 4:24am UTC](https://forum.ionicframework.com/t/how-to-compare-two-array-of-object/131126/1 "2018-05-23T04:24:39Z")

</div>

how to compare two array of object .  
i have a two json array  
**array1**  
**[{“subjectId”:“2”},{“subjectId”:“4”},{“subjectId”:“1”}];**  
**array2**

```auto
[{"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

```auto
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  
}

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:34pm UTC](https://forum.ionicframework.com/t/how-to-compare-two-array-of-object/131126/2 "2021-07-19T21:34:59Z")

</div>

Closed on July 19, 2021, 9:34pm UTC


