function deepClone(obj){ //只考虑数组和对象 if(typeof obj !== 'object' || obj === null) return obj; let result = obj instanceof Array ? []:{}; for(let key in obj){ if(obj.hasOwnProperty(key)){ result[key]= deepClone(obj[key]) } } return result; } let obj = { a:'1212', c:[1,3,5], d:{ e:'333', f:{ g:'ooo' } } } let newObj = deepClone(obj); console.log(newObj);