1234567891011121314151617 |
- /* 深拷贝 */
- export const deepClone = (obj) => {
- const newObj = {};
- let keys = Object.keys(obj);
- let key = null;
- let data = null;
- for(let i = 0; i<keys.length;i++){
- key = keys[i];
- data = obj[key];
- if(data && typeof data === 'object'){
- newObj[key] = deepClone(data)
- }else{
- newObj[key] = data;
- }
- }
- return newObj
- }
|