js对象如何合并?
var o1={hello:1};
var o2={world:2}
怎样合并得到o3{hello:1,world:2}
var extend=function(o,n,override){ for(var p in n) if(n.hasOwnProperty(p) && (!o.hasOwnProperty(p) || override))o[p]=n[p]; }; var o1={hello:1}; var o2={world:2}; extend(o1,o2); alert(o1.world); alert(o1.hello);