jquery merge two objects

后端 未结 5 2171
迷失自我
迷失自我 2021-02-07 04:52

How can I merge jquery objects together

I have

 {
  \"merchantcontract\":\"Ready Reserve Foods 10104.01\",
  \"merchantcontractid\":\"c4253769-5a57-e11         


        
5条回答
  •  心在旅途
    2021-02-07 05:44

    jQuery's $.extend will do what you want.

    //merging two objects into new object
    var new_object = $.extend({}, object1, object2);
    
    //merge object2 into object1
    $.extend(object1, object2);
    

提交回复
热议问题