你的位置:首页 > Java教程

[Java教程]$.extend


var obj1={apple:0,banana:{weight:52,price:100},cherry:97};
$.exytend(obj1);
$.cherry====>97
$.apple=====>0
$.banana====>{weight:52,price:100}
var obj2={banana:{price:100},durian:100}
var obj=$.extend(obj1,obj2):是将obj2合并到obj1中然后返回obj1
JSON.stringify(obj)=====>’{apple:0,banana:{“price":100},cherry:97,durian:100}’;
 
 
 
 
var obj1={apple:0,banana{weight:52,price:100},cherry:97};
var obj2={banana:{price:100},durian:100}
var obj=$.extend(true,obj1,obj2)
JSON.stringify(obj)=====>’{apple:0,banana:{“weight":52,”price":100},cherry:97,durian:100}’;
 
 
ps:JSON.stringify()是用于从一个对象解析出字符串