SOURCE

/**
 * param {array} :待展开的数组
 * param {deep} :展开深度
 */
function spread(array,deep,result){
    result || (result = [])
    deep || (deep = Number.MAX_VALUE)

    for(const value of array){
        if(Array.isArray(value)&&deep > 1){
            spread(value,--deep,result);
        }else{
            result.push(value);
        }
    }

    return result;
}
console.log(spread("123456",1))
console 命令行工具 X clear

                    
>
console