jquery .Extend will merge the contents of two or more objects into the first object
// This will merge the contents of two or more objects into the first object
// I think it can also be said, can be merged aggregated into a entirely new object.
//target, the object will be extended, have the new properties.
//HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>jQuery EXTEND Demo</title>
</head>
<body>
<div id="log"></div>
</body>
</html>
//JS
var object1 = {
apple : 0,
banana: { weight: 52, price: 100 },
cherry: 97
};
var object2 = {
banana: { price: 200 },
kiwi : 65,
watermelon: 400,
};
//Merge object2 into Existing object1
//$.extend( object1, object2 );
//Or create a new object to aggregate them in..
var newObject = $.extend( object1, object2 );
//Assuming JSON.stringify. selecting the log div.
$("#log").append( "New Object Contents" + "</br>" + JSON.stringify(newObject));