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
  • 30,215
  • 7
  • 54
  • 72
Raphael Boukara
  • 398
  • 3
  • 11

2 Answers2

3

You could use jQuery.extend to achieve your desire.

viebel
  • 16,492
  • 10
  • 46
  • 81
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
  • 102,045
  • 43
  • 170
  • 208