针对基本类型及对象类型
function deepClone(data) {
var str, obj = data.constructor === Array ? [] : {};
if (typeof data !== 'object') {
return data;
} else {
for (var i in data) {
obj[i] = typeof data[i] === 'object' ?
deepClone(data[i]) : data[i]; //递归处理嵌套
}
}
return obj;
};