js循环递归函数
var arrayList = {
name: '1', children: [{
name: '2', children: [{
name: '3', children: [{
name: '4', children: []
}]
}]
}]
}
function deep(val) {
if (val.children.length == 0) {
val.children == null
} else {
for (var i = 0; i < val.children.length; i++) {
deep(val.children[i])
}
}
}
deep(arrayList)
一个简单的循环递归函数demo,根据children这个key一直递归向下查
还没有评论,来说两句吧...