var json = {a:6,b:4,c:[1,2,3]};
var json2 = clone(json);
function clone(obj){
var oNew = new obj.constructor(obj.valueOf());
if(obj.constructor == Object){
for(var i in obj){
oNew[i] = obj[i];
if(typeof(oNew[i]) == 'object'){
clone(oNew[i]);
}
}
}
return oNew;
}
转载于:https://www.cnblogs.com/shiyunfront/p/10445535.html