Skip to content

xdash API Reference v0.5.14


xdash API Reference / flatMap

Function: flatMap()

flatMap<T, U>(arr, fn): U[]

Defined in: src/array.ts:237

Flattens an array of arrays.

Type Parameters

T

T

U

U

Parameters

arr

T[]

array to flatten

fn

(x) => U[]

callback to flatten the array

Returns

U[]

the flattened array

Example

ts
flat([[1, 2], [3, 4]], x => x) // returns [1, 2, 3, 4]

Released under the MIT License.