话不多说,上代码
function deepClone(obj) { let newObj = null; if (typeof obj === "object") { newObj = obj instanceof Array ? [] : {}; for (let i in obj) { newObj[i] = deepClone(obj[i]); } } else { newObj = obj; } return newObj; }