Javascript union of two object

This question already has an answer here:

  • How can I merge properties of two JavaScript objects dynamically? 55 answers

  • 你可以使用jQuery.extend来实现你的愿望。


    If you want to join the same keys into arrays like this:

    Object { name: [" ", Array[x]], email: [" ", Array[y]] }
    

    Try looping through each object and push the value:

    var obj3 = {name:[],email:[]};
    
    for(var i in obj1) {
        obj3[i].push(obj1[i]);
    }
    
    for(var i in obj2) {
        obj3[i].push(obj2[i]);
    }
    
    链接地址: http://www.djcxy.com/p/27336.html

    上一篇: 将两个JavaScript对象合并成一个?

    下一篇: 两个对象的Javascript联合