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:{ ...
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()是用於從一個對象解析出字元串