zoukankan      html  css  js  c++  java
  • [摘转] JS 数组合并问题

    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>
  • 相关阅读:
    python--模块
    python--*args与**kw
    python--偏函数
    Reversible Cards ARC111 -B 思维,图论
    Simple Math ARC111
    状压DP详解(位运算)
    E
    Ball CodeForces
    Reward HDU
    Choosing Capital for Treeland CodeForces
  • 原文地址:https://www.cnblogs.com/livon/p/3186784.html
Copyright © 2011-2022 走看看