如题,能帮忙指出下错误么?
function cloneObj(obj) {
if(typeof obj !== "object"){
return obj;
}
var s = {};
if(obj.constructor == Array){
s = [];
}
for(var i in obj){
s[i] = cloneObj(obj[i]);
}
return s;
}
--------------------------------------------------------------------------------------
找到问题所在了, 当obj为null的时候就会报错
![图片描述][1]
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
或者
也是一种选择
这个需要把不可枚举属性排除吧?