/** * 最深层级数组 */ const maxDeepArray = (arr = [1,[2,4],[4], [43,2,[444,1,[54]]], [22,3,[4]], 32]) => { const length = arr.length const fillArray = new Array(length).fill(1) for(let i = 0; i < length; i++){ let value = arr[i] if(Array.isArray(value)){ fillArray[i] += maxDeepArray(value) } } return Math.max(...fillArray) }
标签:arr,层级,const,fillArray,value,length,最深,数组 From: https://www.cnblogs.com/zhenjianyu/p/17085506.html