Skip to content

flattenDeep

flattenDeep(array) → array · Array

Remove ALL levels of array nesting, recursively. Produces a completely flat array.

  • array (required): the deeply nested array to flatten
utlx
{
  deep: flattenDeep([[1, [2, [3, [4]]]]]),
  // [1, 2, 3, 4]
  nested: flattenDeep([[[["deep"]]]]),
  // ["deep"]
  flat: flattenDeep([1, 2, 3])
  // [1, 2, 3]  (already flat — no change)
}

Released under AGPL-3.0.