function clone(obj){
	var type = Object.prototype.toString.call(obj).slice(8,-1).toLowerCase();
	if(type=='object'){
		var json = {};
		for(i in obj){
			if(obj.hasOwnProperty(i)){
				json[i] = clone(obj[i]);
			}
		}
		return json;
	}else if(type=='array'){
		var arr = [];
		for(var i=0; i<obj.length; i++){
			arr[i] = clone(obj[i]);
		}
		return arr;
	}else{
		return obj;
	}
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-07-25
猜你喜欢
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2021-12-01
  • 2021-07-19
  • 2021-12-02
  • 2022-12-23
相关资源
相似解决方案