Javascript, the union of two objects.
Now I do this:

jQuery.extend({}, obj1, obj2); 

It does not work as it should, because obj1 , obj2 this type:

 obj1 = {child_obj,child_obj,child_obj,child_obj,child_obj}; obj2 = {child_obj,child_obj,child_obj,child_obj,child_obj}; 

As a result, I get this type:

 Object {0: Object, 1: Object, 2: Object, 3: Object, 4: Object} 

The problem is that I do not need the numbering of new objects, but to have everything, as in obj1 , obj2 , only already merged.

Thank.

  • Try jQuery.extend (true, {}, obj1, obj2); // deep copy PS I don’t work with Angular, but the search also found the .extend(src, dst) method. - Sergiks
  • @Fikret, do an example on jsfiddle, you will see that it does not work, as you wrote. - stck

0