标签:new 地址 object func 带来 typeof 解决 拷贝 ret
function cloneObj(obj) {
var newObj = {};
if (obj instanceof Array) {
newObj = [];
}
for (var key in obj) {
var val = obj[key];
newObj[key] = typeof val === ‘object‘ ? cloneObj(val): val;
}
return newObj;
};
标签:new 地址 object func 带来 typeof 解决 拷贝 ret
原文地址:http://www.cnblogs.com/AmbitiousMice/p/6813635.html