标签:
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;
}
标签:
原文地址:http://www.cnblogs.com/alisalixue/p/5815646.html