jQuery.extend()

1 var obj1 = {apple:0,banana:{weight:52,price:100},cherry:97};
2 $.extend(obj1)
3 jQuery.cherry  //97
4 jQuery.banana  //Object {weight:52,price:100}
1 var obj1 = {apple:0,banana:{weight:52,price:100},cherry:97};
2 var obj2 = {banana:{price:200},durian:100};
3 var obj = $.extend(obj1,obj2)
4 JSON.stringify(obj)
5 //"{"apple":0,"banana":{"price":200},"cherry":97,"durian":100}"
6 JSON.stringify(obj1)
7 //"{"apple":0,"banana":{"price":200},"cherry":97,"durian":100}"
8 JSON.stringify(obj2)
9 //"{"banana":{"price":200},"durian":100}"
1 var obj = $.extend(tuer,obj1,obj2);
2 JSON.stringify(obj)
3 //"{"apple":0,"banana":{"weight":52,"price":200},"cherry":97,"durian":100}"

jQuery.extend( target [, object1 ] [, objectN ] )

jQuery.extend( [deep ], target, object1 [, objectN ] )

 

 

posted on 2017-03-20 12:11  技术V类  阅读(146)  评论(0编辑  收藏  举报

导航