深拷贝
function deepCopy(target){
if( typeof target !== "object" ) return;
//判断目标类型,来创建返回值
var newObj = target instanceof Array? [] : {}
for(var item in target){
//只复制元素自身的属性,不复制原型链上的
if(target.hasOwnProperty(item)){
newObj[item] = typeof target[item]=="object" ?
deepCopy(target[item]) : target[item]
}
}
return newObj
}
最后
以上就是平常戒指最近收集整理的关于前端面试必考知识点的全部内容,更多相关前端面试必考知识点内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复