SOURCE

const flat = arr => {
  return arr.reduce((pre, cur) => {
    return pre.concat(Array.isArray(cur) ? flat(cur) : cur);
  }, []);
};


console.log(flat([1,2,[3,4]]))
console 命令行工具 X clear

                    
>
console