SOURCE

let list = [1, [2, [3,[4,5]]], 6];
function myflat(n,arr){
    let result=[]
    if(n==0){
        return arr;
    }
    else{
        for(let item of arr){
            console.log(item,'item')
            result = result.concat(myflat(n-1,item))
        }
    }
    return result;
}
console.log(myflat(1,list))
console 命令行工具 X clear

                    
>
console