~~~js function deepClone(obj) { if (obj === null) return null; if (typeof obj !== 'object') return obj; if (obj instanceof Date) { let date = new Date(); date.setTime(obj.getTime()); return date; } if (obj instanceof RegExp) { let re = new RegExp(obj.source); re.lastIndex = obj.lastIndex; return re; } let newObj = new obj.constructor(); for (let key in obj) { if (obj.hasOwnProperty(key)) { newObj[key] = deepClone(obj[key]); } } return newObj; } ~~~ > 本文作者:不爱喝橙子汁