compare the key values from an object in an array where the length of the arrays are not equal

i have two arrays as follows

array1 = {name:"John",surname:"doe",reference:[{name:"jane",surname:"smith"},{name:"kate",surname:"post"}],id:"12364",weight:"50",Oid:"456978",code:"12"}

array2 =  {name:"John",surname:"doe",reference:[{name:"jane",surname:"smith"},{name:"kate",surname:"post"}],id:"4589632",weight:50,policy:"745896",result:"test",documents:"no",launch:"no"}

as you can see both of my lengths of arrays dont match so i can not compare them both.

I would like to compare only certain objects from array 1 and array 2.
for example only the objects that i require

array1
name:"John"
surname:"doe"
reference:[{name:"jane",surname:"smith"},{name:"kate",surname:"post"}]
weight:"50"

array 2
name:"John"
surname:"doe"
reference:[{name:"jane",surname:"smith"},{name:"kate",surname:"post"}]
weight:50

i only want to compare the above objects key values so the above would return true

if i had

 array1
    name:"John"
    surname:"doe"
    reference:[{name:"jane",surname:"smith"},{name:"kate",surname:"post"}]
    weight:"12"

array 2
name:"John"
surname:"Petter"
reference:[{name:"jane",surname:"smith"},{name:"kate",surname:"Knight"}]
weight:50

the above would be false.

how can i achieve this? how can i filter/loop through them to only compare the above mentioned values.

36 thoughts on “compare the key values from an object in an array where the length of the arrays are not equal”

  1. 428290 118586An intriguing discussion will probably be worth comment. I believe which you basically write considerably more about this topic, it may become a taboo subject but generally consumers are inadequate to communicate in on such topics. To one more. Cheers 273430

    Reply