数组reduce 方法 (arr.reduce )

arr.reduce

var list = arr.reduce(function (total,level0) {

    level0.subTagList.forEach(function (level1) {
      level1.subTagList.forEach(function (level2) { 
          if(level2.state){
            total.push({
              name: level0.tagName + '/' + level1.tagName + '/' + level2.tagName,
              id: level2.id,
            });
          }
       });
    });
    return total;
  },[]);
posted @ 2022-11-09 14:57  李帆同学  阅读(85)  评论(0编辑  收藏  举报
TOP