$.extend
2016-08-08 10:18 改吧 阅读(456) 评论(0) 编辑 收藏 举报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()是用于从一个对象解析出字符串