Javascript examples for Array Operation:Array of Object
Merge two array of objects in javascript
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w ww. j av a 2s. c om*/ function addChildren(master, child){ return master.map(function(elem, i){ elem.child = elem.child || []; elem.child.push(child[i]); return elem; }); }; console.log(addChildren([{a:1},{b:2}],[{k:3},{h:2}])); } </script> </head> <body> </body> </html>