function deepClone(obj) { if(obj == null) return obj; // null == undefined if(obj instanceof Date) return new Date(obj); if(obj instanceof RegExp) return new RegExp(obj); if(typeof obj != 'object') return obj; let newObj = new obj.constructor; for(let key in obj) { newObj[key] = deepClone(obj[key]); } return newObj; }
①JSON.stringify複製對象特色
②一步步推導出的深拷貝
③jquery中extend拷貝方法
④Object.create拷貝方法html