javascript : 递归遍历数组

我们假设有一个对象数组。

这个对象数组里的对象,有一个叫children的key,value也是一个对象数组。

这个数组里面可能还有children...

现在我们想递归遍历它。

上代码。

test_parse(source){
            for (var key in source) {
                console.log(source[key])
                if (source[key].children) {
                    this.test_parse(source[key].children)
                }
            }
        },

以上。

posted on 2019-04-14 19:28  fox_charon  阅读(6202)  评论(0编辑  收藏  举报

导航