

es5的写法
function clone(obj) {
if(obj == null) return null;
let newObj = obj instanceof Array ? [] : {};
for(var i in obj) {
newObj[i] = typeof obj[i] == "object" ? clone(obj[i]) : obj[i];
}
return newObj;
}es6的写法
const clone2 = (obj) => {
let proto = Object.getPrototypeOf(obj);
return Object.assign({}, Object.create(proto), obj)
}