深拷貝函數bash
function deeCopy(obj){
var result = Array.isArray(obj) ? [] : {};
for (var key in obj) {
if(obj.hasOwnProperty(key)) {
if(typeof obj[key] === "object") {
result[key] = deeCopy(obj[key]);
} else {
result[key] = obj[key];
}
}
}
return result;
}
複製代碼