function copyObj(oldObj){ var newObj = Array.isArray(oldObj) ? [] :{}; for(var p in oldObj){ if(typeof oldObj[p]== 'object'){ newObj[p] ==copyObj(oldObj[p]) }else{ newObj[p] = oldObj[p]; } } return newObj; }
本文共 313 字,大约阅读时间需要 1 分钟。
function copyObj(oldObj){ var newObj = Array.isArray(oldObj) ? [] :{}; for(var p in oldObj){ if(typeof oldObj[p]== 'object'){ newObj[p] ==copyObj(oldObj[p]) }else{ newObj[p] = oldObj[p]; } } return newObj; }
转载于:https://www.cnblogs.com/qqfontofweb/p/6699758.html