I need to merge an array of objects. I am aware of jquery extend method
extend( target [, object1 ] [, objectN ] )
and that it can merge any number of objects.
But how do I loop through my array of the objects and merge them using this method?
I need to merge an array of objects. I am aware of jquery extend method
extend( target [, object1 ] [, objectN ] )
and that it can merge any number of objects.
But how do I loop through my array of the objects and merge them using this method?
 
    
    solved it:
  var object1 = {
  'perm-1': 1,
  'perm-2': 2,
  'perm-3': 3
};
var object2 = {
  'perm-1': 1,
  'perm-5': 5
};
var object3 = {
  'perm-6': 6,
  'perm-7': 7
};
var realArray = []
realArray.push(object1)
realArray.push(object2)
realArray.push(object3)
var target = {}
for(i=0; i<realArray.length; i++)
{
    $.extend(target, realArray[i])
}
$( "#log" ).append( JSON.stringify( target ) );
