function deepCopy(target) {
let result;
if (Object.prototype.toString.call(target) === "[object Array]") {
result = [];
target.forEach((element) => {
result.push(deepCopy(element));
});
} else if (Object.prototype.toString.call(target) === "[object Object]") {
result = {};
Object.keys(target).forEach((key) => {
result[key] = deepCopy(target[key]);
});
} else {
result = target;
}
return result;
}
参考:
https://www.csdn.net/tags/MtjacgysMjEyNzMtYmxvZwO0O0OO0O0O.html