复制代码 代码如下:
CSSCommonJS.DeepCopy = function (json) {
if (typeof json == 'number' || typeof json == 'string' || typeof json == 'boolean') {
return json;
} else if (typeof json == 'object') {
if (json instanceof Array) {
var newArr = [], i, len = json.length;
for (i = 0; i < len; i++) {
newArr[i] = arguments.callee(json[i]);
}
return newArr;
} else {
var newObj = {};
for (var name in json) {
newObj[name] = arguments.callee(json[name]);
}
return newObj;
}
}
}
CSSCommonJS.DeepCopy = function (json) {
if (typeof json == 'number' || typeof json == 'string' || typeof json == 'boolean') {
return json;
} else if (typeof json == 'object') {
if (json instanceof Array) {
var newArr = [], i, len = json.length;
for (i = 0; i < len; i++) {
newArr[i] = arguments.callee(json[i]);
}
return newArr;
} else {
var newObj = {};
for (var name in json) {
newObj[name] = arguments.callee(json[name]);
}
return newObj;
}
}
}
标签:
复制,js对象,方法
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“复制js对象方法(详解)”评论...