js数组深拷贝
2019-10-10 本文已影响0人
革易
原文链接https://www.jianshu.com/p/a0077ea28dcb
// 数组拷贝
copyArr (obj) {
var out = []
var i = 0
var len = obj.length
for (; i < len; i++) {
if (obj[i] instanceof Array) {
out[i] = this.copyArr(obj[i])
} else {
out[i] = obj[i]
}
}
return out
}