博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js复制对象
阅读量:4684 次
发布时间:2019-06-09

本文共 1325 字,大约阅读时间需要 4 分钟。

<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&emsp;</font>\n"+dataIndustry);
var test={};
extend(test,dataIndustry);
test={}; //改变test属性
alert("<font color='red'>1dataIndustry&emsp;</font>\n"+dataIndustry);
alert(test);

</script>

转载于:https://www.cnblogs.com/tancp/p/3763390.html

你可能感兴趣的文章
MySQL批量SQL插入性能优化
查看>>
定义列属性:null,default,PK,auto_increment
查看>>
用户画像展示
查看>>
pyqt pyinstaller使用说明
查看>>
C#中StreamReader读取中文出现乱码
查看>>
引用堆中的对象
查看>>
用CSS开启硬件加速来提高网站性能(转)
查看>>
使用BufferedReader的时候出现的问题
查看>>
加快页面加载速度的方法
查看>>
Oozie协作框架
查看>>
linux安装图形界面
查看>>
Android广播发送失败
查看>>
博弈论之入门小结
查看>>
解决IE8下opacity属性失效问题,无法隐藏元素
查看>>
洛谷1002 过河卒
查看>>
C#匿名函数的坑
查看>>
标记页面控件尺寸
查看>>
批处理文件中的路径问题
查看>>
appium+python 环境搭建
查看>>
WampServer下修改和重置MySQL密码
查看>>