js 深克隆和浅克隆
(1)深克隆
var clone = function(obj){
let o = obj.constructor()===Array? []:{};
for(let key in obj)
{
o[key] = typeof obj[key] === "Objbect"? clone(obj[key]):obj[key];
}
return o;
}
(2)浅克隆
var copy = function(obj){
let o = {};
for(let key in obj)
{
o[key] = obj[key];
}
o.uber = obj;
return o;
}