SOURCE

// flat 函数扁平数组
function _flat(arr){
  return arr.reduce((cur,next)=>{
    if(Array.isArray(next)){
      return [...cur,_flat(next)]
    }else {
      return [...cur,next]
    }
  },[])
  
}
var arr = [1,2,3,[4,5,6,[7,8,9]]]
var b = _flat(arr)
console.log(b)
console.log(Array.isArray(b))
console 命令行工具 X clear

                    
>
console