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... "
月关宝盒
慕森王
相关分类