Skip to content

flat ​

2023-06-16 10:28:26

ts
const _flatten = arr => {
  const res = []
  arr.map(item => {
    if (Array.isArray(item)) {
      res.push(..._flatten(item))
    } else {
      res.push(item)
    }
  })
  return res
}

Released under the MIT License.