6

I have one object:

Object { name: " ", email: " " }

and another:

Object { name: Array[x], email: Array[y]}

and I want union like:

Object { name: {" ", Array[x]}, email: {" ", Array[y]} }
cнŝdk
  • 31,391
  • 7
  • 56
  • 78
Raphael Boukara
  • 398
  • 3
  • 11

2 Answers2

3

You could use jQuery.extend to achieve your desire.

viebel
  • 19,372
  • 10
  • 49
  • 83
0

If you want to join the same keys into arrays like this:

Object { name: [" ", Array[x]], email: [" ", Array[y]] }

Try looping through each object and push the value:

var obj3 = {name:[],email:[]};

for(var i in obj1) {
    obj3[i].push(obj1[i]);
}

for(var i in obj2) {
    obj3[i].push(obj2[i]);
}
David Hellsing
  • 106,495
  • 44
  • 176
  • 212