http://zhidao.baidu.com/question/113956153.html
arr1 = {a:1, b:2, c:3};
arr2 = {b:5, h:6, k:7};
结果{a:1, b:5, c:3, h:6, k:7}
1 <!--STATUS OK--> 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 3 <html> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 6 <title>JS 数组合并问题_百度知道</title> 7 8 <link rel="alternate" type="application/rss+xml" 9 title="“JS 数组合并问题”的最新回答(RSS 2.0)" 10 href="http://zhidao.baidu.com/q?ct=20&qid=113956153&pn=65535&rn=25&tn=rssqb"> 11 12 </head> 13 <body> 14 <script> 15 function objConcat(a1, a2) { 16 var newarr = {}; 17 for ( var k1 in a1) { 18 newarr[k1] = a1[k1]; 19 } 20 for ( var k2 in a2) { 21 newarr[k2] = a2[k2]; 22 } 23 return newarr; 24 } 25 26 arr1 = { 27 a : 1, 28 b : 2, 29 c : 3 30 }; 31 arr2 = { 32 b : 5, 33 h : 6, 34 k : 7 35 }; 36 arr = objConcat(arr1, arr2); 37 for ( var key in arr) { 38 document.write(key + '->' + arr[key] + '</br>'); 39 } 40 </script> 41 </body> 42 </html>