标签:span first length log class 先决条件 递归 pre this
递归使用过程中的两个先决条件: 1. 要递归的条件。 2. 递归结束的条件。 Eg: var thisArr = function(arr) { var new_arr = []; for(var i = 0; i < arr.length; i++){ if(Array.isArray(arr[i])){ thisArr(arr[i]); }else{ new_arr.push(arr[i]); } } }; function ladding(){ var arr = [1,2,3,4,5,["a","b","c","d","e",["A","B","C","D","E",["FIRST","SECOND","THIRED","FOURED","FIRED"]]]]; thisArr(arr); console.log(new_arr); }
标签:span first length log class 先决条件 递归 pre this
原文地址:https://www.cnblogs.com/tanjiyuan/p/12468390.html