js复制对象
<script type="text/javascript">
function getType(o)
{
var _t;
return ((_t = typeof(o)) == "object" ? o==null && "null" || Object.prototype.toString.call(o).slice(8,-1):_t).toLowerCase();
}
function extend(destination,source)
{
for(var p in source)
{
if(getType(source[p])=="array"||getType(source[p])=="object")
{
destination[p]=getType(source[p])=="array"?[]:{};
arguments.callee(destination[p],source[p]);
}
else
{
destination[p]=source[p];
}
}
}
/* *******************************************************************************************************/
var dataIndustry ={
getInsustryId: function(){ return $("#insustryId").val()},
getName:function(){return $('#name').val();},
getCode:function(){return $('#code').val();},
getRank:function(){return $('#rank').val();},
getIsLeaf:function(){return $('#isLeaf').val();},
getDescription:function(){return $('#description').val();},
getStatus:function(){return $('#status').val();}
}
/* *******************************************************************************************************/
debugger ;
alert("<font color='red'>1dataIndustry </font>\n"+dataIndustry);
var test={};
extend(test,dataIndustry);
test={}; //改变test属性
alert("<font color='red'>1dataIndustry </font>\n"+dataIndustry);
alert(test);
</script>