function deepcopy(obj) {
//归
if (typeof obj != 'object') {
return obj;
}
//递
var newObj = {};
for (var attr in obj) {
newObj[attr] = deepcopy[attr];
}
return newObj[attr];
};
var x = {
"a":{
"b":"old"
}
};
var x2 = deepcopy(x);
x2.a.b = "new";
console.log(x.a.b); //真是奇葩,为何老提示could not read propery"a",not defined... "
添加回答
举报
0/150
提交
取消