Javascript examples for Array Operation:Associative Array
Merge arrays that are on the same key
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from w ww. j av a2s . c o m h1 = {12: [{actor: 'wayne'}, {actor: 'bill'}], 13: [{actor: 'james'}]} h2 = {13: [{actor: 'mark'}]} for (var k in h2) { h1[k]=(h1[k]||[]).concat(h2[k]); } console.log(h1); }); </script> </head> <body> </body> </html>