flatten
arrayFlattens array a single level deep.
Signature
flatten<T>(array: T[]): T[]Parameters
| Name | Type | Description |
|---|---|---|
array | T[] | The array to flatten |
Returns
T[] - Returns the new flattened array
Examples
Basic Usage
import { flatten } from 'dashlite'
const result = flatten([1, [2, [3, [4]], 5]])
console.log(result)Output:
[1, 2, [3, [4]], 5]Available since version 1.0.0