function shallowCopy(obj) {if (!obj) return obj;
// 只拷贝对象
if (typeof obj !== 'object') {return}
var newObj = Array.isArray(obj) ? [] : {}
for(var key in obj) {if (obj.hasOwnProperty(key)) {newObj[key] = obj[key]
}
}
return newObj
}
function deepCopy(obj) {if (!obj) return obj;
// 只拷贝数组和对象
if (typeof obj !== 'object') {return}
var newobj = Array.isArray(obj) ? []: {};
for (var key in obj) {if (obj.hasOwnProperty(key)) {newobj[key] = (typeof obj[key] === 'object') ? deepCopy(obj[key]) : obj[key]
}
}
return newobj
}