Skip to content

实现数组平铺函数

js
const flat = (arr) =>
  arr.reduce((a, b) => a.concat(typeof b === "object" ? flat(b) : b), []);
const flat = (arr) =>
  arr.reduce((a, b) => a.concat(typeof b === "object" ? flat(b) : b), []);