JS 递归

今日同事遇到递归问题 

function isExpandedLeftCategory(node) {
      .....
      if (A==B) {
        return true;
      } else {
        for (var i = 0; i < childrenList.length; i++) {
            isExpandedLeftCategory(childrenList[i]);
        }
      }
  }
//  return undefined

  

总结原因,递归需要return返回; 使用:return isExpandedLeftCategory(childrenList[i]);即可

 

posted @ 2019-09-25 15:16  Loki-Liu  阅读(167)  评论(0)    收藏  举报