javascript 深拷贝
function deepCopy(data) {
var type = Object.prototype.toString.call(data);
var o = null;
if(type === '[object array]') {
o = [];
for (var i = 0; i < data.length; i++){
o.push(deepCopy(data[i]));
}
}else if(type === '[object object]') {
o = {};
for(var i in data) {
o[i] = deepCopy(data[i]);
}
}else {
o = data;
}
return o;
}
生活需要正能量,不忘初心,方的始终