function deepClone(obj){ function isObject(o){ return (typeof o === 'object' || typeof o === 'function') && o !== null } if(!isObject(obj)){return obj} let newObj = Array.isArray(obj) ? [] : {} for(key in obj){ if(obj.hasOwnProperty(key)){ newObj[key] = isObject(obj[key]) ? deepClone(obj[key]) : obj[key] } } return newObj }
hasOwnProperty 判断该属性是否为对象的自有属性